diff options
author | Claudio André <claudioandre.br@gmail.com> | 2017-04-26 17:29:56 -0300 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2017-04-27 22:49:06 -0700 |
commit | 67a0d7e955460dbd1cd28c7c7fa45ddc3edcfea1 (patch) | |
tree | 5cb2f7ae47e80830a29c58bd83c183df74f8a1bb | |
parent | 2ef72a1fddd349c1eb2e67e315c14b6c791615c1 (diff) | |
download | gjs-67a0d7e955460dbd1cd28c7c7fa45ddc3edcfea1.tar.gz |
maintenance: modernize shell scripts
It is possible to use a static analysis tool to improve all scripts robustness and safety.
https://bugzilla.gnome.org/show_bug.cgi?id=781806
-rwxr-xr-x | installed-tests/scripts/testCommandLine.sh | 24 | ||||
-rwxr-xr-x | installed-tests/scripts/testWarnings.sh | 6 |
2 files changed, 15 insertions, 15 deletions
diff --git a/installed-tests/scripts/testCommandLine.sh b/installed-tests/scripts/testCommandLine.sh index c51a302d..2e0d55e8 100755 --- a/installed-tests/scripts/testCommandLine.sh +++ b/installed-tests/scripts/testCommandLine.sh @@ -1,9 +1,9 @@ #!/bin/sh if test "$GJS_USE_UNINSTALLED_FILES" = "1"; then - gjs="$TOP_BUILDDIR"/gjs-console + gjs="$TOP_BUILDDIR/gjs-console" else - gjs=gjs-console + gjs="gjs-console" fi # This JS script should exit immediately with code 42. If that is not working, @@ -31,7 +31,7 @@ total=0 report () { exit_code=$? - total=`expr $total + 1` + total=$((total + 1)) if test $exit_code -eq 0; then echo "ok $total - $1" else @@ -41,7 +41,7 @@ report () { report_xfail () { exit_code=$? - total=`expr $total + 1` + total=$((total + 1)) if test $exit_code -ne 0; then echo "ok $total - $1" else @@ -65,39 +65,39 @@ report "System.exit() should still exit across an FFI boundary" # gjs --help prints GJS help "$gjs" --help >/dev/null report "--help should succeed" -test -n "`"$gjs" --help`" +test -n "$("$gjs" --help)" report "--help should print something" # print GJS help even if it's not the first argument "$gjs" -I . --help >/dev/null report "should succeed when --help is not first arg" -test -n "`"$gjs" -I . --help`" +test -n "$("$gjs" -I . --help)" report "should print something when --help is not first arg" # --help before a script file name prints GJS help "$gjs" --help help.js >/dev/null report "--help should succeed before a script file" -test -n "`"$gjs" --help help.js`" +test -n "$("$gjs" --help help.js)" report "--help should print something before a script file" # --help before a -c argument prints GJS help script='imports.system.exit(1)' "$gjs" --help -c "$script" >/dev/null report "--help should succeed before -c" -test -n "`"$gjs" --help -c "$script"`" +test -n "$("$gjs" --help -c "$script")" report "--help should print something before -c" # --help after a script file name is passed to the script "$gjs" -I sentinel help.js --help report "--help after script file should be passed to script" -test -z "`"$gjs" -I sentinel help.js --help`" +test -z "$("$gjs" -I sentinel help.js --help)" report "--help after script file should not print anything" # --help after a -c argument is passed to the script script='if(ARGV[0] !== "--help") imports.system.exit(1)' "$gjs" -c "$script" --help report "--help after -c should be passed to script" -test -z "`"$gjs" -c "$script" --help`" +test -z "$("$gjs" -c "$script" --help)" report "--help after -c should not print anything" # -I after a program is not consumed by GJS @@ -116,14 +116,14 @@ rm -f foo/coverage.lcov # --version works "$gjs" --version >/dev/null report "--version should work" -test -n "`"$gjs" --version`" +test -n "$("$gjs" --version)" report "--version should print something" # --version after a script goes to the script script='if(ARGV[0] !== "--version") imports.system.exit(1)' "$gjs" -c "$script" --version report "--version after -c should be passed to script" -test -z "`"$gjs" -c "$script" --version`" +test -z "$("$gjs" -c "$script" --version)" report "--version after -c should not print anything" rm -f exit.js help.js diff --git a/installed-tests/scripts/testWarnings.sh b/installed-tests/scripts/testWarnings.sh index f95dd9ab..ebf3143c 100755 --- a/installed-tests/scripts/testWarnings.sh +++ b/installed-tests/scripts/testWarnings.sh @@ -1,16 +1,16 @@ #!/bin/sh if test "$GJS_USE_UNINSTALLED_FILES" = "1"; then - gjs="$TOP_BUILDDIR"/gjs-console + gjs="$TOP_BUILDDIR/gjs-console" else - gjs=gjs-console + gjs="gjs-console" fi total=0 report () { exit_code=$? - total=`expr $total + 1` + total=$((total + 1)) if test $exit_code -eq 0; then echo "ok $total - $1" else |