#18756 closed defect (fixed)
Fix shellcheck warnings of shellscripts
| Reported by: | simon04 | Owned by: | simon04 |
|---|---|---|---|
| Priority: | normal | Milestone: | 20.02 |
| Component: | Core | Version: | |
| Keywords: | bash shell | Cc: | sebastic |
Description
https://www.shellcheck.net/ – ShellCheck, a static analysis tool for shell scripts
$ shellcheck linux/tested/usr/bin/josm
In linux/tested/usr/bin/josm line 7:
ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`"
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
Did you mean:
ALTERNATIVE_JDK="$(readlink -n -f /etc/alternatives/java)"
In linux/tested/usr/bin/josm line 10:
ARCH="`dpkg --print-architecture 2> /dev/null || true`"
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
Did you mean:
ARCH="$(dpkg --print-architecture 2> /dev/null || true)"
In linux/tested/usr/bin/josm line 16:
|| dpkg --get-selections 'openjdk-*-jre:$ARCH' | grep install$ > /dev/null ; then
^-------------------^ SC2016: Expressions don't expand in single quotes, use double quotes for that.
In linux/tested/usr/bin/josm line 33:
. /etc/default/josm
^---------------^ SC1091: Not following: /etc/default/josm was not specified as input (see shellcheck -x).
In linux/tested/usr/bin/josm line 40:
if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
^--------------------^ SC2006: Use $(...) notation instead of legacy backticked `...`.
^---^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
if [ "z$ALTERNATIVE_JDK" = "z$(readlink -n -f "$jcmd")" ] && [ -z "${JAVACMD}" ]; then
In linux/tested/usr/bin/josm line 49:
if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
In linux/tested/usr/bin/josm line 58:
if [ "`expr match \"${JAVACMD}\" 'java-9'`" != "0" ] || [ "`expr match \"${JAVACMD}\" 'java-10'`" != "0" ]; then
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
Did you mean:
if [ "$(expr match \"${JAVACMD}\" 'java-9')" != "0" ] || [ "$(expr match \"${JAVACMD}\" 'java-10')" != "0" ]; then
In linux/tested/usr/bin/josm line 60:
elif [ "`expr match \"${JAVACMD}\" 'java-1'`" != "0" ]; then
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
Did you mean:
elif [ "$(expr match \"${JAVACMD}\" 'java-1')" != "0" ]; then
In linux/tested/usr/bin/josm line 65:
$JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
^--------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
$JAVACMD "$JAVA_OPTS" -jar /usr/share/josm/josm.jar "$@"
For more information:
https://www.shellcheck.net/wiki/SC2166 -- Prefer [ p ] && [ q ] as [ p -a q...
https://www.shellcheck.net/wiki/SC1091 -- Not following: /etc/default/josm ...
https://www.shellcheck.net/wiki/SC2016 -- Expressions don't expand in singl...
Attachments (0)
Change History (11)
comment:1 by , 6 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:3 by , 6 years ago
In POSIX sh, [[ ]] is undefined – https://www.shellcheck.net/wiki/SC2039
Is the Bash requirement a major concern?
comment:4 by , 6 years ago
| Cc: | added |
|---|---|
| Keywords: | bash shell added |
@sebastic: is it a problem for Debian if our shell scripts explicitly target bash?
comment:6 by , 6 years ago
| Milestone: | 20.03 → 20.02 |
|---|
follow-up: 8 comment:7 by , 6 years ago
The josm laucher script is broken in 15927:
Using /usr/lib/jvm/java-11-openjdk-amd64/bin/java to execute josm. Unrecognized option: --add-modules java.scripting,java.sql -Djosm.restart=true -Djava.net.useSystemProxies=true Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
This is caused by quoting $JAVA_OPTS, fixed with:
$JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
comment:9 by , 6 years ago
It was most definitely broken with josm (0.0.svn15927+dfsg-1) in Debian unstable.
Which package are you using on buster? The offending changes in 15927 are not in buster-backports yet.
comment:10 by , 6 years ago
I use latest from JOSM and tested from Debian buster-backports.
Had no problem, with version 1.5.svn15927.
Might be Debian related.



In 15916/josm: