on master help sign in
handle input carefully in shell scripts
076cfe2Thirnearez
manage.sh+18−18
@@ -1,11 +1,11 @@
1#!/bin/sh
1#!/bin/sh
2
2
3−BASE_DIR=$(dirname "`readlink -f "$0"`")
3+BASE_DIR="$(dirname -- "`readlink -f -- "$0"`")"
4−PYTHONPATH=$BASE_DIR
4+PYTHONPATH="$BASE_DIR"
5SEARX_DIR="$BASE_DIR/searx"
5SEARX_DIR="$BASE_DIR/searx"
6−ACTION=$1
6+ACTION="$1"
7
7
8−cd "$BASE_DIR"
8+cd -- "$BASE_DIR"
9
9
10update_packages() {
10update_packages() {
11 pip install --upgrade pip
11 pip install --upgrade pip
@@ -24,12 +24,12 @@ install_geckodriver() {
24 set -e
24 set -e
25 geckodriver -V > /dev/null 2>&1 || NOTFOUND=1
25 geckodriver -V > /dev/null 2>&1 || NOTFOUND=1
26 set +e
26 set +e
27− if [ -z $NOTFOUND ]; then
27+ if [ -z "$NOTFOUND" ]; then
28 return
28 return
29 fi
29 fi
30 GECKODRIVER_VERSION="v0.18.0"
30 GECKODRIVER_VERSION="v0.18.0"
31− PLATFORM=`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`
31+ PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`"
32− case $PLATFORM in
32+ case "$PLATFORM" in
33 "linux 32bit" | "linux2 32bit") ARCH="linux32";;
33 "linux 32bit" | "linux2 32bit") ARCH="linux32";;
34 "linux 64bit" | "linux2 64bit") ARCH="linux64";;
34 "linux 64bit" | "linux2 64bit") ARCH="linux64";;
35 "windows 32 bit") ARCH="win32";;
35 "windows 32 bit") ARCH="win32";;
@@ -47,15 +47,15 @@ install_geckodriver() {
47 fi
47 fi
48 else
48 else
49 GECKODRIVER_DIR="$1"
49 GECKODRIVER_DIR="$1"
50− mkdir -p "$GECKODRIVER_DIR"
50+ mkdir -p -- "$GECKODRIVER_DIR"
51 fi
51 fi
52
52
53 echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL"
53 echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL"
54
54
55− FILE=`mktemp`
55+ FILE="`mktemp`"
56− wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C "$GECKODRIVER_DIR" -f $FILE geckodriver
56+ wget -qO "$FILE" -- "$GECKODRIVER_URL" && tar xz -C "$GECKODRIVER_DIR" -f "$FILE" geckodriver
57− rm $FILE
57+ rm -- "$FILE"
58− chmod 777 "$GECKODRIVER_DIR/geckodriver"
58+ chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
59}
59}
60
60
61pep8_check() {
61pep8_check() {
@@ -73,14 +73,14 @@ unit_tests() {
73
73
74py_test_coverage() {
74py_test_coverage() {
75 echo '[!] Running python test coverage'
75 echo '[!] Running python test coverage'
76− PYTHONPATH=`pwd` python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \
76+ PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \
77 && coverage report \
77 && coverage report \
78 && coverage html
78 && coverage html
79}
79}
80
80
81robot_tests() {
81robot_tests() {
82 echo '[!] Running robot tests'
82 echo '[!] Running robot tests'
83− PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot
83+ PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot
84}
84}
85
85
86tests() {
86tests() {
@@ -113,11 +113,11 @@ styles() {
113
113
114npm_packages() {
114npm_packages() {
115 echo '[!] install NPM packages for oscar theme'
115 echo '[!] install NPM packages for oscar theme'
116− cd $BASE_DIR/searx/static/themes/oscar
116+ cd -- "$BASE_DIR/searx/static/themes/oscar"
117 npm install
117 npm install
118
118
119 echo '[!] install NPM packages for simple theme'
119 echo '[!] install NPM packages for simple theme'
120− cd $BASE_DIR/searx/static/themes/simple
120+ cd -- "$BASE_DIR/searx/static/themes/simple"
121 npm install
121 npm install
122}
122}
123
123
@@ -133,7 +133,7 @@ locales() {
133}
133}
134
134
135help() {
135help() {
136− [ -z "$1" ] || printf "Error: $1\n"
136+ [ -z "$1" ] || printf 'Error: %s\n' "$1"
137 echo "Searx manage.sh help
137 echo "Searx manage.sh help
138
138
139Commands
139Commands
@@ -156,4 +156,4 @@ Commands
156
156
157[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
157[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
158 && help "action not found" \
158 && help "action not found" \
159− || $ACTION "$2"
159+ || "$ACTION" "$2"
utils/update-translations.sh+3−3
@@ -7,9 +7,9 @@
7
7
8SEARX_DIR='searx'
8SEARX_DIR='searx'
9
9
10−pybabel extract -F babel.cfg -o messages.pot $SEARX_DIR
10+pybabel extract -F babel.cfg -o messages.pot "$SEARX_DIR"
11−for f in `ls $SEARX_DIR'/translations/'`; do
11+for f in `ls "$SEARX_DIR"'/translations/'`; do
12− pybabel update -N -i messages.pot -d $SEARX_DIR'/translations/' -l $f
12+ pybabel update -N -i messages.pot -d "$SEARX_DIR"'/translations/' -l "$f"
13done
13done
14
14
15echo '[!] update done, edit .po files if required and run pybabel compile -d searx/translations/'
15echo '[!] update done, edit .po files if required and run pybabel compile -d searx/translations/'