Skip to content

Commit 607108d

Browse files
Misc: Allow directories with spaces in extractor.sh (#31648)
1 parent 7b85a01 commit 607108d

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

contrib/extractor.sh

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22

33
# Set client and server directories as environment variables
44
# if you don't want to enter them here
5-
if [ -z $CLIENT_DIR ]; then
5+
if [ -z "$CLIENT_DIR" ]; then
66
echo -n "Enter directory where client files are located: "
77
read CLIENT_DIR
88

9-
if ! cd $CLIENT_DIR; then
9+
if ! cd "$CLIENT_DIR"; then
1010
echo "Cannot access $CLIENT_DIR"
1111
exit 1
1212
fi
13-
if [ ! -d $CLIENT_DIR/Data ]; then
13+
if [ ! -d "$CLIENT_DIR/Data" ]; then
1414
echo "Cannot find client files in $CLIENT_DIR"
1515
exit 1
1616
fi
1717
fi
1818

19-
if [ -z $SERVER_DIR ]; then
19+
if [ -z "$SERVER_DIR" ]; then
2020
echo -n "Enter directory where server files are located: "
2121
read SERVER_DIR
2222

23-
if ! cd $SERVER_DIR; then
23+
if ! cd "$SERVER_DIR"; then
2424
echo "Cannot access $SERVER_DIR"
2525
exit 1
2626
fi
2727
fi
2828

2929
# These should all be correct on a standard installation
30-
DATA_DIR=${SERVER_DIR}/data
31-
MAPEXTRACTOR=${SERVER_DIR}/bin/mapextractor
32-
VMAP4EXTRACTOR=${SERVER_DIR}/bin/vmap4extractor
33-
VMAP4ASSEMBLER=${SERVER_DIR}/bin/vmap4assembler
34-
MMAPS_GENERATOR=${SERVER_DIR}/bin/mmaps_generator
30+
DATA_DIR="${SERVER_DIR}/data"
31+
MAPEXTRACTOR="${SERVER_DIR}/bin/mapextractor"
32+
VMAP4EXTRACTOR="${SERVER_DIR}/bin/vmap4extractor"
33+
VMAP4ASSEMBLER="${SERVER_DIR}/bin/vmap4assembler"
34+
MMAPS_GENERATOR="${SERVER_DIR}/bin/mmaps_generator"
3535

3636
check_files() {
37-
for i in $MAPEXTRACTOR $VMAP4EXTRACTOR $VMAP4ASSEMBLER $MMAPS_GENERATOR
37+
for i in "$MAPEXTRACTOR" "$VMAP4EXTRACTOR" "$VMAP4ASSEMBLER" "$MMAPS_GENERATOR"
3838
do
3939
if [[ ! -x $i ]]
4040
then
@@ -62,23 +62,23 @@ echo "Extracting DBC, Camera and Maps files"
6262
echo
6363
echo "-- Using $MAPEXTRACTOR"
6464
echo "-- Copying extracted data to ${DATA_DIR}"
65-
if [[ ! -d ${DATA_DIR} ]]
65+
if [[ ! -d "${DATA_DIR}" ]]
6666
then
6767
echo "-- Creating ${DATA_DIR}"
68-
mkdir ${DATA_DIR}
68+
mkdir "${DATA_DIR}"
6969
fi
7070
echo "-- Starting in 5 seconds"
7171
sleep 5
7272

73-
cd ${CLIENT_DIR}
74-
$MAPEXTRACTOR
73+
cd "${CLIENT_DIR}"
74+
"$MAPEXTRACTOR"
7575

7676
echo "-- Extraction complete, copying dbc and maps files"
77-
cp -r dbc maps ${DATA_DIR}
78-
if [[ -d ${CLIENT_DIR}/Cameras ]]
77+
cp -r dbc maps "${DATA_DIR}"
78+
if [[ -d "${CLIENT_DIR}/Cameras" ]]
7979
then
8080
echo "-- Camera files found, copying"
81-
cp -r Cameras ${DATA_DIR}
81+
cp -r Cameras "${DATA_DIR}"
8282
fi
8383

8484
echo "-- Done"
@@ -95,13 +95,13 @@ echo "-- Copying extracted data to ${DATA_DIR}/vmaps"
9595
echo "-- Starting in 5 seconds"
9696
sleep 5
9797

98-
cd ${CLIENT_DIR}
99-
$VMAP4EXTRACTOR
98+
cd "${CLIENT_DIR}"
99+
"$VMAP4EXTRACTOR"
100100
mkdir vmaps
101-
$VMAP4ASSEMBLER Buildings vmaps
101+
"$VMAP4ASSEMBLER" Buildings vmaps
102102

103103
echo "-- Extraction complete, copying files"
104-
cp -r vmaps ${DATA_DIR}
104+
cp -r vmaps "${DATA_DIR}"
105105
echo "-- Done"
106106
echo
107107
}
@@ -115,11 +115,11 @@ echo "-- Copying extracted data to ${DATA_DIR}/mmaps"
115115
echo "-- Starting in 5 seconds"
116116
sleep 5
117117

118-
cd ${CLIENT_DIR}
118+
cd "${CLIENT_DIR}"
119119
mkdir mmaps
120-
$MMAPS_GENERATOR
120+
"$MMAPS_GENERATOR"
121121
echo "-- Extraction complete, copying files"
122-
cp -r mmaps ${DATA_DIR}
122+
cp -r mmaps "${DATA_DIR}"
123123
echo "-- Done"
124124
echo
125125
}
@@ -135,7 +135,7 @@ echo "Enter y to continue or anything else to cancel"
135135
read a
136136
if [[ ${a} = "y" ]]
137137
then
138-
cd ${CLIENT_DIR}
138+
cd "${CLIENT_DIR}"
139139
rm -fr Buildings Cameras dbc maps mmaps vmaps
140140
echo "Done"
141141
fi

0 commit comments

Comments
 (0)