From 90a6c6d46bbc630b36c414e3e598455dea94459e Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Thu, 13 Jun 2019 12:53:26 +0100 Subject: [PATCH] Fix issues reported by ShellCheck --- create_db.sh | 4 ++-- extract_dataset_parts.sh | 4 ++-- run_tests.sh | 9 ++++----- scripts/cleanup_datasets/delete_datasets.sh | 4 ++-- .../delete_userless_histories.sh | 4 ++-- scripts/cleanup_datasets/populate_uuid.sh | 4 ++-- scripts/cleanup_datasets/purge_datasets.sh | 4 ++-- scripts/cleanup_datasets/purge_folders.sh | 4 ++-- scripts/cleanup_datasets/purge_histories.sh | 4 ++-- scripts/cleanup_datasets/purge_libraries.sh | 4 ++-- scripts/cleanup_datasets/update_metadata.sh | 2 +- scripts/maintenance.sh | 4 ++-- scripts/migrate_tools/0002_tools.sh | 4 ++-- scripts/migrate_tools/0003_tools.sh | 4 ++-- scripts/migrate_tools/0004_tools.sh | 4 ++-- scripts/migrate_tools/0005_tools.sh | 4 ++-- scripts/migrate_tools/0006_tools.sh | 4 ++-- scripts/migrate_tools/0007_tools.sh | 4 ++-- scripts/migrate_tools/0008_tools.sh | 4 ++-- scripts/migrate_tools/0009_tools.sh | 4 ++-- scripts/migrate_tools/0010_tools.sh | 4 ++-- scripts/migrate_tools/0011_tools.sh | 4 ++-- scripts/migrate_tools/0012_tools.sh | 4 ++-- .../tool_shed/migrate_tools_to_repositories.sh | 2 +- scripts/validate_tools.sh | 16 +++++++--------- 25 files changed, 55 insertions(+), 58 deletions(-) diff --git a/create_db.sh b/create_db.sh index 8c77eff858d6..3c34dd6c3e57 100755 --- a/create_db.sh +++ b/create_db.sh @@ -1,9 +1,9 @@ #!/bin/sh -cd `dirname $0` +cd "$(dirname "$0")" . ./scripts/common_startup_functions.sh setup_python -python ./scripts/create_db.py $@ +python ./scripts/create_db.py "$@" diff --git a/extract_dataset_parts.sh b/extract_dataset_parts.sh index f17ced8bcd50..7591b4a5ae3a 100755 --- a/extract_dataset_parts.sh +++ b/extract_dataset_parts.sh @@ -1,6 +1,6 @@ #!/bin/sh -cd `dirname $0` +cd "$(dirname "$0")" . ./scripts/common_startup_functions.sh @@ -9,5 +9,5 @@ setup_python for file in $1/split_info*.json do # echo processing $file - python ./scripts/extract_dataset_part.py $file + python ./scripts/extract_dataset_part.py "$file" done diff --git a/run_tests.sh b/run_tests.sh index a72f96257bbf..1236e8742cc8 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,7 +1,6 @@ #!/bin/sh -pwd_dir=$(pwd) -cd `dirname $0` +cd "$(dirname "$0")" rm -f run_functional_tests.log @@ -318,8 +317,8 @@ then -e "GALAXY_TEST_DATABASE_TYPE=$db_type" \ -e "LC_ALL=C" \ --rm \ - -v `pwd`:/galaxy \ - -v `pwd`/test/docker/base/run_test_wrapper.sh:/usr/local/bin/run_test_wrapper.sh $DOCKER_IMAGE "$@" + -v "$(pwd)":/galaxy \ + -v "$(pwd)"/test/docker/base/run_test_wrapper.sh:/usr/local/bin/run_test_wrapper.sh "$DOCKER_IMAGE" "$@" exit $? fi @@ -607,7 +606,7 @@ elif [ -n "$toolshed_script" ]; then elif [ -n "$api_script" ]; then extra_args="$api_script" elif [ -n "$section_id" ]; then - extra_args=`python tool_list.py $section_id` + extra_args=$(python tool_list.py "$section_id") elif [ -n "$unit_extra" ]; then extra_args="$unit_extra" elif [ -n "$integration_extra" ]; then diff --git a/scripts/cleanup_datasets/delete_datasets.sh b/scripts/cleanup_datasets/delete_datasets.sh index 501c234a8d5a..e7dfb3f68744 100644 --- a/scripts/cleanup_datasets/delete_datasets.sh +++ b/scripts/cleanup_datasets/delete_datasets.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -6 -r $@ >> ./scripts/cleanup_datasets/delete_datasets.log +cd "$(dirname "$0")"/../.. +python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -6 -r "$@" >> ./scripts/cleanup_datasets/delete_datasets.log diff --git a/scripts/cleanup_datasets/delete_userless_histories.sh b/scripts/cleanup_datasets/delete_userless_histories.sh index 72d68db72ec4..9bb8c70882f9 100644 --- a/scripts/cleanup_datasets/delete_userless_histories.sh +++ b/scripts/cleanup_datasets/delete_userless_histories.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -1 $@ >> ./scripts/cleanup_datasets/delete_userless_histories.log +cd "$(dirname "$0")"/../.. +python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -1 "$@" >> ./scripts/cleanup_datasets/delete_userless_histories.log diff --git a/scripts/cleanup_datasets/populate_uuid.sh b/scripts/cleanup_datasets/populate_uuid.sh index ac2028462cf6..c12c5240c19b 100644 --- a/scripts/cleanup_datasets/populate_uuid.sh +++ b/scripts/cleanup_datasets/populate_uuid.sh @@ -1,5 +1,5 @@ #!/bin/sh -cd `dirname $0`/../.. +cd "$(dirname "$0")"/../.. export PYTHONPATH=./lib/ -python ./scripts/cleanup_datasets/populate_uuid.py ./config/galaxy.ini $@ +python ./scripts/cleanup_datasets/populate_uuid.py ./config/galaxy.ini "$@" diff --git a/scripts/cleanup_datasets/purge_datasets.sh b/scripts/cleanup_datasets/purge_datasets.sh index e4405015c500..6d5c12bb8806 100644 --- a/scripts/cleanup_datasets/purge_datasets.sh +++ b/scripts/cleanup_datasets/purge_datasets.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -3 -r $@ >> ./scripts/cleanup_datasets/purge_datasets.log +cd "$(dirname "$0")"/../.. +python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -3 -r "$@" >> ./scripts/cleanup_datasets/purge_datasets.log diff --git a/scripts/cleanup_datasets/purge_folders.sh b/scripts/cleanup_datasets/purge_folders.sh index ff970d0ac8eb..d02b7671e6f4 100644 --- a/scripts/cleanup_datasets/purge_folders.sh +++ b/scripts/cleanup_datasets/purge_folders.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -5 -r $@ >> ./scripts/cleanup_datasets/purge_folders.log +cd "$(dirname "$0")"/../.. +python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -5 -r "$@" >> ./scripts/cleanup_datasets/purge_folders.log diff --git a/scripts/cleanup_datasets/purge_histories.sh b/scripts/cleanup_datasets/purge_histories.sh index 66e9f3d285fb..8c7ff274d4a1 100644 --- a/scripts/cleanup_datasets/purge_histories.sh +++ b/scripts/cleanup_datasets/purge_histories.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -2 -r $@ >> ./scripts/cleanup_datasets/purge_histories.log +cd "$(dirname "$0")"/../.. +python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -2 -r "$@" >> ./scripts/cleanup_datasets/purge_histories.log diff --git a/scripts/cleanup_datasets/purge_libraries.sh b/scripts/cleanup_datasets/purge_libraries.sh index 6a96b30268de..9e66e05cb5cd 100644 --- a/scripts/cleanup_datasets/purge_libraries.sh +++ b/scripts/cleanup_datasets/purge_libraries.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -4 -r $@ >> ./scripts/cleanup_datasets/purge_libraries.log +cd "$(dirname "$0")"/../.. +python ./scripts/cleanup_datasets/cleanup_datasets.py -d 10 -4 -r "$@" >> ./scripts/cleanup_datasets/purge_libraries.log diff --git a/scripts/cleanup_datasets/update_metadata.sh b/scripts/cleanup_datasets/update_metadata.sh index 7933a0d9ebb8..a78325d8ee7a 100644 --- a/scripts/cleanup_datasets/update_metadata.sh +++ b/scripts/cleanup_datasets/update_metadata.sh @@ -6,4 +6,4 @@ . ./scripts/get_python.sh . ./setup_paths.sh -$GALAXY_PYTHON ./scripts/cleanup_datasets/update_metadata.py ./config/galaxy.ini $@ +"$GALAXY_PYTHON" ./scripts/cleanup_datasets/update_metadata.py ./config/galaxy.ini "$@" diff --git a/scripts/maintenance.sh b/scripts/maintenance.sh index 8ca4771ed548..e45d11bb6034 100755 --- a/scripts/maintenance.sh +++ b/scripts/maintenance.sh @@ -6,7 +6,7 @@ set -e display_help(){ - scriptname=`basename $0` + scriptname=$(basename "$0") printf "./$scriptname [--help] [--no-dry-run] [--days 10] Will run the galaxy cleanup scripts in the recommend order. By default a 'dry-run' is started. Specify --no-dry-run to do the actual cleanup. @@ -52,7 +52,7 @@ do esac done -cd "$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"/../ +cd "$(dirname "$0")"/.. . scripts/common_startup_functions.sh diff --git a/scripts/migrate_tools/0002_tools.sh b/scripts/migrate_tools/0002_tools.sh index 926aba9529de..7262196b5a91 100644 --- a/scripts/migrate_tools/0002_tools.sh +++ b/scripts/migrate_tools/0002_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0002_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0002_tools.xml "$@" diff --git a/scripts/migrate_tools/0003_tools.sh b/scripts/migrate_tools/0003_tools.sh index dfc3bde56b38..f8a1ba8bb165 100644 --- a/scripts/migrate_tools/0003_tools.sh +++ b/scripts/migrate_tools/0003_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0003_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0003_tools.xml "$@" diff --git a/scripts/migrate_tools/0004_tools.sh b/scripts/migrate_tools/0004_tools.sh index 40b76956fa2a..7ae608f36838 100644 --- a/scripts/migrate_tools/0004_tools.sh +++ b/scripts/migrate_tools/0004_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0004_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0004_tools.xml "$@" diff --git a/scripts/migrate_tools/0005_tools.sh b/scripts/migrate_tools/0005_tools.sh index c9f1f3c61d67..da7f9c090987 100644 --- a/scripts/migrate_tools/0005_tools.sh +++ b/scripts/migrate_tools/0005_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0005_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0005_tools.xml "$@" diff --git a/scripts/migrate_tools/0006_tools.sh b/scripts/migrate_tools/0006_tools.sh index 1f000ebeca6b..ff85522a5f9b 100644 --- a/scripts/migrate_tools/0006_tools.sh +++ b/scripts/migrate_tools/0006_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0006_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0006_tools.xml "$@" diff --git a/scripts/migrate_tools/0007_tools.sh b/scripts/migrate_tools/0007_tools.sh index a6cf948593d8..8a88f44420c4 100644 --- a/scripts/migrate_tools/0007_tools.sh +++ b/scripts/migrate_tools/0007_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0007_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0007_tools.xml "$@" diff --git a/scripts/migrate_tools/0008_tools.sh b/scripts/migrate_tools/0008_tools.sh index 50cafd19936b..d312237023b0 100644 --- a/scripts/migrate_tools/0008_tools.sh +++ b/scripts/migrate_tools/0008_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0008_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0008_tools.xml "$@" diff --git a/scripts/migrate_tools/0009_tools.sh b/scripts/migrate_tools/0009_tools.sh index 36f162b141cd..78242fe24222 100644 --- a/scripts/migrate_tools/0009_tools.sh +++ b/scripts/migrate_tools/0009_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0009_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0009_tools.xml "$@" diff --git a/scripts/migrate_tools/0010_tools.sh b/scripts/migrate_tools/0010_tools.sh index fde17704dd39..03c65dd99731 100644 --- a/scripts/migrate_tools/0010_tools.sh +++ b/scripts/migrate_tools/0010_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0010_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0010_tools.xml "$@" diff --git a/scripts/migrate_tools/0011_tools.sh b/scripts/migrate_tools/0011_tools.sh index a31365804fdc..e06a6be40b36 100644 --- a/scripts/migrate_tools/0011_tools.sh +++ b/scripts/migrate_tools/0011_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0011_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0011_tools.xml "$@" diff --git a/scripts/migrate_tools/0012_tools.sh b/scripts/migrate_tools/0012_tools.sh index 97fbe354d04e..2df312f980a9 100644 --- a/scripts/migrate_tools/0012_tools.sh +++ b/scripts/migrate_tools/0012_tools.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. -python ./scripts/migrate_tools/migrate_tools.py 0012_tools.xml $@ +cd "$(dirname "$0")"/../.. +python ./scripts/migrate_tools/migrate_tools.py 0012_tools.xml "$@" diff --git a/scripts/tool_shed/migrate_tools_to_repositories.sh b/scripts/tool_shed/migrate_tools_to_repositories.sh index e1108e20307e..bbab9b1b333b 100644 --- a/scripts/tool_shed/migrate_tools_to_repositories.sh +++ b/scripts/tool_shed/migrate_tools_to_repositories.sh @@ -1,4 +1,4 @@ #!/bin/sh -cd `dirname $0`/../.. +cd "$(dirname "$0")"/../.. python ./scripts/tool_shed/migrate_tools_to_repositories.py ./community_wsgi.ini >> ./scripts/tool_shed/migrate_tools_to_repositories.log diff --git a/scripts/validate_tools.sh b/scripts/validate_tools.sh index 11a52c2f0aaa..f57c1cb814a1 100755 --- a/scripts/validate_tools.sh +++ b/scripts/validate_tools.sh @@ -1,33 +1,31 @@ #!/bin/sh -cd `dirname $0`/.. +cd "$(dirname "$0")"/.. GALAXY_SKIP_CLIENT_BUILD=1 ./scripts/common_startup.sh GALAXY_VIRTUAL_ENV="${GALAXY_VIRTUAL_ENV:-.venv}" -if [ -d "$GALAXY_VIRTUAL_ENV" ]; -then +if [ -d "$GALAXY_VIRTUAL_ENV" ]; then printf "Activating virtualenv at $GALAXY_VIRTUAL_ENV\n" . "$GALAXY_VIRTUAL_ENV/bin/activate" fi xsd_path="lib/galaxy/tool_util/xsd/galaxy.xsd" -err_tmp=`mktemp` +err_tmp=$(mktemp) count=0 exit=0 for p in "$@"; do count=$((count+1)) path="$p" - echo $path + echo "$path" PYTHONPATH=lib:$PYTHONPATH export PYTHONPATH - result=`python -c "import galaxy.tool_util.loader; import xml.etree; xml.etree.ElementTree.dump(galaxy.tool_util.loader.load_tool('$path').getroot())" | xmllint --nowarning --noout --schema "$xsd_path" - 2> "$err_tmp"` - if [ $? -eq 0 ] - then + python -c "import galaxy.tool_util.loader; import xml.etree; xml.etree.ElementTree.dump(galaxy.tool_util.loader.load_tool('$path').getroot())" | xmllint --nowarning --noout --schema "$xsd_path" - 2> "$err_tmp" + if [ $? -eq 0 ]; then echo "ok $count"; else echo "not ok $count $path"; - cat "$err_tmp" | sed 's/^/ /' + sed 's/^/ /' "$err_tmp" exit=1 fi done