Fix issues reported by ShellCheck in tsp 31/81831/12
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Fri, 26 Aug 2016 14:43:02 +0000 (16:43 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 6 Dec 2016 15:37:13 +0000 (16:37 +0100)
Move check_diff() to tsp/jobs/img_test_common.sh
Add newline at the end of 'modifed_paths' in tsp/scripts/crawler.py
so that whole lines instead of words can be read.

ShellCheck: https://github.com/koalaman/shellcheck
shellcheck -e SC1090,SC2155,SC2068,SC2145,SC2164 `find tsp -name "*.sh"`

output should report following problems only:
    tsp/common.sh: SC2148, SC2034, SC2139
    tsp/jobs/trigger_downloads.sh: SC2115
    tsp/jobs/common_prep_flash_conf.sh: SC2029
    tsp/jobs/publish.sh: SC2046, SC2029

Change-Id: I7791769a0d653c784715cdd1a8b1446fafcba1e9
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
13 files changed:
tsp/common.sh
tsp/jobs/common_prep_flash_conf.sh
tsp/jobs/img_test_common.sh
tsp/jobs/publish.sh
tsp/jobs/trigger_downloads.sh
tsp/jobs/watch_diskspace.sh
tsp/jobs/watcher.sh
tsp/scripts/common_prep_flash_conf.sh
tsp/scripts/crawler.py
tsp/scripts/free_diskspace.sh
tsp/scripts/log.sh
tsp/scripts/publish.sh
tsp/stop.sh

index 7e07d08..0be6bbd 100755 (executable)
@@ -24,7 +24,7 @@
 
 die() {
     printf >&2 -- '%s\n' "$1"
-    exit ${2:-1}
+    exit "${2:-1}"
 }
 
 test -z "${TSP_DIR}" || export TS_ONFINISH="${TSP_DIR}/scripts/log.sh"
@@ -59,19 +59,3 @@ tsrun_target() {
     shift
     TMPDIR="$TMPDIR" TS_SLOTS=1 tsp $@
 }
-
-check_diff() {
-    DIFF_FILE="$1"
-    JOB_NR="$2"
-    TARGET="$3"
-    test -n "$1" || die "Missing argument: diff file"
-    test -n "$2" || die "Missing argument: build nr"
-    test -n "$3" || die "Missing argument: target"
-    test -n "${TSP_DIR}" || die "Missing environment variable: TSP_DIR"
-    if grep -q "identical" "${DIFF_FILE}"
-    then
-        echo "Image is unchanged in respect to snapshot"
-        nr=`tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh ${JOB_NR} ${TARGET}`
-        return 1
-    fi
-}
index aeb06d3..2e12e84 100755 (executable)
@@ -16,7 +16,7 @@
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
@@ -26,19 +26,18 @@ TARGET="$2"
 test -n "${BUILD_NR}" || die "Missing argument: build nr"
 test -n "$TARGET" || die "Missing argument: target"
 
-WORKDIR="${WS_TEST}/${BUILD_NR}"
 WORKDIR_REMOTE="${WS_TEST_REMOTE}/${BUILD_NR}"
 DWN_WORKDIR="${WS_DOWNLOAD}/${BUILD_NR}"
 
 
 case "$TARGET" in
     *odroid*)
-        BOOT_IMG="`ls ${DWN_WORKDIR}/tizen-common_*-boot-*.tar.gz`"
-        USERSPACE_IMG="`ls ${DWN_WORKDIR}/tizen-common_*-wayland-*.tar.gz`"
+        BOOT_IMG="$(ls "${DWN_WORKDIR}"/tizen-common_*-boot-*.tar.gz)"
+        USERSPACE_IMG="$(ls "${DWN_WORKDIR}"/tizen-common_*-wayland-*.tar.gz)"
         ;;
     *minnow*)
-        USERSPACE_IMG="`ls ${DWN_WORKDIR}/tizen-common_*-wayland-*-sda.raw.bz2`"
-        USERSPACE_IMG_BMAP="`ls ${DWN_WORKDIR}/tizen-common_*-wayland-*-sda.bmap`"
+        USERSPACE_IMG="$(ls "${DWN_WORKDIR}"/tizen-common_*-wayland-*-sda.raw.bz2)"
+        USERSPACE_IMG_BMAP="$(ls "${DWN_WORKDIR}"/tizen-common_*-wayland-*-sda.bmap)"
         ;;
 esac
 
@@ -49,14 +48,14 @@ retrigger() {
     # Add job back to the queue
     echo "Retrigger... ($1)"
     echo "FAILED 1" > sysctl.result
-    tsrun_target "${TARGET}" -L "RETRIGGERED_$(echo "$TARGET" | tr 'a-z' 'A-Z')_PREPARE_FLASH_CONF" \
-        sh "${TSP_DIR}/jobs/common_prep_flash_conf.sh" "$BUILD_NR" "${TARGET}" "$(($FAIL_CNT + 1))"
+    tsrun_target "${TARGET}" -L "RETRIGGERED_$(echo "$TARGET" | tr '[:lower:]' '[:upper:]')_PREPARE_FLASH_CONF" \
+        sh "${TSP_DIR}/jobs/common_prep_flash_conf.sh" "$BUILD_NR" "${TARGET}" "$((FAIL_CNT + 1))"
     exit 0
 }
 
 if [ "$FAIL_CNT" -ge 2 ]; then
     # Trigger publish job
-    tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$BUILD_NR" "$TARGET"
+    tspwb -L PUBLISH sh "${TSP_DIR}/jobs/publish.sh" "$BUILD_NR" "$TARGET"
     exit 1
 fi
 
@@ -82,9 +81,11 @@ echo "finish remote script"
 # Copy the results
 scp tl-runner:"${WORKDIR_REMOTE}/sysctl.result" .
 
-echo "RETRIGGER_CNT ${FAIL_CNT}" >> sysctl.result
-echo "Build nr: $BUILD_NR" >> sysctl.result
-echo "Date: `date`" >> sysctl.result
+{
+    echo "RETRIGGER_CNT ${FAIL_CNT}"
+    echo "Build nr: ${BUILD_NR}"
+    echo "Date: $(date)"
+} >> sysctl.result
 
 # Check if they have run successfully, otherwise reschedule the job
 if grep -q "Testing failed." sysctl.result
@@ -93,4 +94,4 @@ then
 fi
 
 # Trigger publish job
-tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$BUILD_NR" "$TARGET"
+tspwb -L PUBLISH sh "${TSP_DIR}/jobs/publish.sh" "$BUILD_NR" "$TARGET"
index a412abb..4df6f34 100755 (executable)
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
 test -n "$1" || die "Missing argument: build nr"
 
 WORKDIR="${WS_TEST}/$1"
-WORKDIR_REMOTE="${WS_TEST_REMOTE}/$1"
 DWN_WORKDIR="${WS_DOWNLOAD}/$1"
-
 TARGET="$2"
 
+check_diff() {
+    DIFF_FILE="$1"
+    JOB_NR="$2"
+    TARGET="$3"
+    test -n "$1" || die "Missing argument: diff file"
+    test -n "$2" || die "Missing argument: build nr"
+    test -n "$3" || die "Missing argument: target"
+    test -n "${TSP_DIR}" || die "Missing environment variable: TSP_DIR"
+    if grep -q "identical" "${DIFF_FILE}"
+    then
+        echo "Image is unchanged in respect to snapshot"
+        tspwb -L PUBLISH sh "${TSP_DIR}/jobs/publish.sh" "${JOB_NR}" "${TARGET}"
+        return 1
+    fi
+}
+
 test -n "$TARGET" || die "Missing argument: target"
 
 
 case "$TARGET" in
     *minnow*)
-        PROJECT_FILE="${DWN_WORKDIR}/project-minnow.conf"
         DIFF_FILE="${DWN_WORKDIR}/diff-minnow.report"
         ;;
     *)
-        PROJECT_FILE="${DWN_WORKDIR}/project-${TARGET}.conf"
         DIFF_FILE="${DWN_WORKDIR}/diff-${TARGET}.report"
         ;;
 esac
 rm -rf "${WORKDIR}"
 mkdir -p "${WORKDIR}"
 cd "${WORKDIR}"
-if $(check_diff "${DIFF_FILE}" "$1" "${TARGET}");
+if check_diff "${DIFF_FILE}" "$1" "${TARGET}";
 then
     echo "Add common_prep_flash_conf job to the $TARGET queue"
-    tsrun_target $TARGET -L "$(echo "$TARGET" | tr 'a-z' 'A-Z')_PREPARE_FLASH_CONF" \
+    tsrun_target "$TARGET" -L "$(echo "$TARGET" | tr '[:lower:]' '[:upper:]')_PREPARE_FLASH_CONF" \
         sh "${TSP_DIR}/jobs/common_prep_flash_conf.sh" "$1" "${TARGET}"
 fi
index 5beac85..868208e 100755 (executable)
@@ -16,7 +16,7 @@
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
@@ -40,7 +40,7 @@ get_value_of_key_from_dict() {
     test -n "$KEY" || die "Missing argument: key"
     test -n "$DICT" || die "Missing argument: dict"
 
-    VALUE="`awk -v KEY="${KEY}" '$1 == KEY {print $2}' $DICT`"
+    VALUE="$(awk -v KEY="${KEY}" '$1 == KEY {print $2}' "$DICT")"
 
     echo "$VALUE"
 }
@@ -57,7 +57,7 @@ get_all_pairs() {
         "JOURNAL_TOTAL_CNT" "JOURNAL_DIFF_CNT" "SERVICES_FAIL_CNT"
     do
         # FILE is read every time because sh does not preserve file endings (zsh does)
-        eval "${PREFIX}${key}"=`get_value_of_key_from_dict $key $FILE`
+        eval "${PREFIX}${key}"=$(get_value_of_key_from_dict "$key" "$FILE")
     done
 }
 
@@ -97,8 +97,8 @@ compare_with_snapshot() {
     echo "OK"
 }
 
-PROJECT_FILE="`ls ${DWN_WORKDIR}/project-*.conf`"
-DIFF_FILE="`ls ${DWN_WORKDIR}/diff-*.report`"
+PROJECT_FILE="$(ls "${DWN_WORKDIR}/project-*.conf")"
+DIFF_FILE="$(ls "${DWN_WORKDIR}/diff-*.report")"
 SYSCTL_FILE="${IMG_WORKDIR}/sysctl.result"
 SNAPSHOT_SYSCTL_FILE="${WS_TEST}/snapshot_sysctl_${TARGET}"
 TAG_FILE="${IMG_WORKDIR}/tag"
@@ -133,7 +133,7 @@ init_db() {
 
 test -f "${DBPATH}" || init_db
 
-SR="`head -n 1 ${PROJECT_FILE}`"
+SR=$(head -n 1 "${PROJECT_FILE}")
 
 echo "SR: $SR"
 echo "TAG: $TAG"
@@ -145,9 +145,11 @@ sqlite3 "${DBPATH}" "insert into test values (NULL,'$SR', CURRENT_TIMESTAMP, $BU
     (select d.did from device d where d.dname='$TARGET'));"
 
 # Publish to www
-cat "${TSP_DIR}/html_head" > "${WWW_PUBLISH}"
-${TSP_DIR}/scripts/publish.py "${DBPATH}" >> "${WWW_PUBLISH}"
-cat "${TSP_DIR}/html_tail" >> "${WWW_PUBLISH}"
+{
+    cat "${TSP_DIR}/html_head"
+    "${TSP_DIR}/scripts/publish.py" "${DBPATH}"
+    cat "${TSP_DIR}/html_tail"
+} > "${WWW_PUBLISH}"
 
 # Clean up workspace
 ssh tl-pwb "rm -rf \"${WORKSPACE}\"; mkdir -p \"${WORKSPACE}\"" || echo "rm failed"
index 0155397..c336a2f 100755 (executable)
@@ -16,7 +16,7 @@
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
@@ -25,16 +25,23 @@ cd "${WS_WATCHER}"
 touch next_dwn
 i=$(cat next_dwn)
 test -n "$i" || i=1
-for url in $(cat modified_urls manual_urls | sort -u)
+if [ -f manual_urls ];
+then
+    sort -u modified_urls manual_urls > unique_dispatch
+else
+    cp modified_urls unique_dispatch
+fi
+while read -r url
 do
+    test -n "${url}" || continue
     echo "Processing: ${url}"
-    if [ $url = "*latest*" ]
+    if [ "$url" = "*latest*" ]
     then
         echo "Skipping symlink url"
         continue
     fi
     # kill currently running jobs for this url
-    for i in $(tsmaster | awk -v URL="$url" '$2 ~ "running" && $0 ~ URL {print $1}'); do kill `tsmaster -p $i`; done
+    for i in $(tsmaster | awk -v URL="$url" '$2 ~ "running" && $0 ~ URL {print $1}'); do kill "$(tsmaster -p "$i")"; done
     for target in "minnow32" "minnow64" "odroid"
     do
         rm -rf "${WS_DOWNLOAD}/$i"
@@ -43,10 +50,10 @@ do
         # Download image for $target
         nr=$(tsmaster -L "DOWNLOAD_IMAGE_${target}" python "${TSP_DIR}/scripts/download_image.py" --log=INFO "--${target}" "$url")
         nr=$(tsmaster -D "$nr" -L "IMAGE_TEST" \
-            sh ${TSP_DIR}/jobs/img_test_common.sh "$i" "$target")
+            sh "${TSP_DIR}/jobs/img_test_common.sh" "$i" "$target")
         i=$((i+1))
     done
-done
+done < unique_dispatch
 cd "${WS_WATCHER}"
 echo "$i" > "next_dwn"
-rm -f manual_urls
+rm -f unique_dispatch modified_urls manual_urls
index 296015e..b4acd1f 100755 (executable)
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
 # Assume workspaces are stored on root partition.
 # Get diskspace usage for root mountpoint.
-PER=`df -Ph | grep -o "[0-9][0-9]%.*/$"`
+PER="$(df -Ph | grep -o "[0-9][0-9]%.*/$")"
 # Leave only numerical value.
-PER=${PER%\%*}
+PER="${PER%\%*}"
 if [ "$PER" -ge 70 ]
 then
-    nr=$(tsmaster -L DISK_CLEANUP sh "${TSP_DIR}/scripts/free_diskspace.sh")
+    nr="$(tsmaster -L DISK_CLEANUP sh "${TSP_DIR}/scripts/free_diskspace.sh")"
     # make the above job urgent
     tsmaster -u "$nr"
 fi
index a18a698..7ef9c5b 100755 (executable)
@@ -16,7 +16,7 @@
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
@@ -26,6 +26,6 @@ touch dispatched_urls
 touch timestamp
 touch timestamp_snapshot
 nr=$(tspoll -L PRERELEASE_WATCHER timeout 120 "${TSP_DIR}/scripts/crawler.py" --log INFO "http://download.tizen.org/prerelease/tizen/common/")
-nr=$(tspoll -D $nr -L DOWNLOAD_TRIGGER sh "${TSP_DIR}/jobs/trigger_downloads.sh")
-nr=$(tspoll -D $nr -L SNAPSHOT_WATCHER timeout 120 "${TSP_DIR}/scripts/crawler.py" --log INFO "http://download.tizen.org/snapshots/tizen/common/")
-tspoll -D $nr -L DOWNLOAD_TRIGGER sh "${TSP_DIR}/jobs/trigger_downloads.sh"
+nr=$(tspoll -D "$nr" -L DOWNLOAD_TRIGGER sh "${TSP_DIR}/jobs/trigger_downloads.sh")
+nr=$(tspoll -D "$nr" -L SNAPSHOT_WATCHER timeout 120 "${TSP_DIR}/scripts/crawler.py" --log INFO "http://download.tizen.org/snapshots/tizen/common/")
+tspoll -D "$nr" -L DOWNLOAD_TRIGGER sh "${TSP_DIR}/jobs/trigger_downloads.sh"
index 07e3d46..d940823 100755 (executable)
 
 TESTLAB_MAJOR="/opt/testlab-major"
 
-cd "${WORKDIR_REMOTE}"
+cd "${WORKDIR_REMOTE}" || exit
 case "$TARGET" in
     *odroid*)
-        BOOT_IMG="`pwd`/`ls tizen-common_*-boot-*.tar.gz`"
-        USR_IMG="`pwd`/`ls tizen-common_*-wayland-*.tar.gz`"
+        BOOT_IMG="$(pwd)/$(ls tizen-common_*-boot-*.tar.gz)"
+        USR_IMG="$(pwd)/$(ls tizen-common_*-wayland-*.tar.gz)"
         ;;
     *minnow*)
-        USR_IMG="`pwd`/`ls tizen-common_*_common-*-sda.raw.bz2`"
-        USR_IMG_BMAP="`pwd`/`ls tizen-common_*_common-*-sda.bmap`"
+        USR_IMG="$(pwd)/$(ls tizen-common_*_common-*-sda.raw.bz2)"
+        USR_IMG_BMAP="$(pwd)/$(ls tizen-common_*_common-*-sda.bmap)"
         ;;
 esac
 
 # Make sure that userspace image exists
-if [ "${USR_IMG}" = "`pwd`/" ]; then
+if [ "${USR_IMG}" = "$(pwd)/" ]; then
     echo "Image not found." > sysctl.result
     exit 1
 else
@@ -53,10 +53,10 @@ fi
 
 case "$TARGET" in
     *odroid*)
-        ${TESTLAB_MAJOR}/tct/odroid_prepare_flash_conf.sh "$SDMUX" "$USR_IMG" "$BOOT_IMG"
+        "${TESTLAB_MAJOR}/tct/odroid_prepare_flash_conf.sh" "$SDMUX" "$USR_IMG" "$BOOT_IMG"
         ;;
     *minnow*)
-        ${TESTLAB_MAJOR}/tct/minnow_prepare_flash_conf.sh "$SDMUX" "$USR_IMG"
+        "${TESTLAB_MAJOR}/tct/minnow_prepare_flash_conf.sh" "$SDMUX" "$USR_IMG"
         ;;
 esac
 
index bbc6704..7f73075 100755 (executable)
@@ -137,7 +137,7 @@ if '__main__' == __name__:
     # save discovered URLs for dispatching download requests
     modified = get_modified_paths(discovered, timestamp_file)
     with open(discovered_urls, 'w') as f:
-        f.write('\n'.join(modified))
+        f.write('\n'.join(modified) + '\n')
 
     # save all URLs for storing download history
     dispatched |= modified
index 566005c..9adf7d6 100755 (executable)
 # Assume that most of the space is taken up by downloaded images.
 # Delete ones that were modified at least 3 days ago.
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
 for i in $(find "${WS_DOWNLOAD}" -maxdepth 1 -mindepth 1 -type d -mtime +1)
 do
-    DIFF_FILE="$(ls $i/diff-*.report)"
+    DIFF_FILE="$(ls "$i"/diff-*.report)"
     if [ -z "${DIFF_FILE}" ]
     then
         echo "Missing diff-*.report in: " "$i"
index bd29684..32e2829 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo $@ >> /tmp/testlab.log
+echo "$@" >> /tmp/testlab.log
index 523bb6c..ffe18b6 100755 (executable)
@@ -25,16 +25,17 @@ WORKSPACE="/home/jenkins/pub"
 cd "$WORKSPACE"
 
 ### Project list
-FULL_PROJECT="`head -1 project.conf`"
+FULL_PROJECT="$(head -1 project.conf)"
 PROJECT="${FULL_PROJECT##*_}"
 PAGE="Image test results"
 
-echo -n "" > "${OUTPUT}"
-echo "${PAGE_START}" >> "${OUTPUT}"
-echo "${TITLE_TAG}${PAGE}${TITLE_TAG}" >> "${OUTPUT}"
-echo '[['"${PROJECT}"']]' >> "${OUTPUT}"
-echo "" >> "${OUTPUT}"
-echo "${PAGE_END}" >> "${OUTPUT}"
+{
+    echo "${PAGE_START}"
+    echo "${TITLE_TAG}${PAGE}${TITLE_TAG}"
+    echo '[['"${PROJECT}"']]'
+    echo ""
+    echo "${PAGE_END}"
+} > "${OUTPUT}"
 
 python3 /srv/pwb/pwb.py get "${PAGE}" | grep "\[\[${PROJECT}\]\]" \
 || python3 /srv/pwb/pwb.py pagefromfile -start:"${PAGE_START}" -end:"${PAGE_END}" -appendtop \
@@ -43,9 +44,10 @@ python3 /srv/pwb/pwb.py get "${PAGE}" | grep "\[\[${PROJECT}\]\]" \
 ### Detailed project page
 PAGE="${PROJECT}"
 
-echo -n "" > "${OUTPUT}"
-echo "${PAGE_START}" >> "${OUTPUT}"
-echo "${TITLE_TAG}${PAGE}${TITLE_TAG}" >> "${OUTPUT}"
+{
+    echo "${PAGE_START}"
+    echo "${TITLE_TAG}${PAGE}${TITLE_TAG}"
+} > "${OUTPUT}"
 
 tail -2 project.conf >> "${OUTPUT}" || echo "No project"
 awk '{print " "$0}' sysctl.result >> "${OUTPUT}" || echo "No sysctl"
index 77e727b..24dd63b 100755 (executable)
@@ -16,7 +16,7 @@
 
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
-export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
 
 . "${TSP_DIR}/common.sh"
 
@@ -27,7 +27,7 @@ kill_running() {
     echo "[$@] Kill every running job"
     for i in $(eval $@ | grep "running" | grep -o "^[0-9]*")
     do
-        kill `eval $@ -p $i`
+        kill "$(eval $@ -p "$i")"
     done
 }
 
@@ -35,7 +35,7 @@ remove_queued() {
     echo "[$@] Remove every queued job"
     for i in $(eval $@ | grep "queued" | grep -o "^[0-9]*")
     do
-        eval $@ -r $i
+        eval $@ -r "$i"
     done
 }