Closed CaveNightingale closed 1 year ago
Here is a report for the script from an online POSIX compatibility testing website.
[Line 7:](javascript:setPosition(7, 11))
if ! test $1
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([0])), apply [all SC2086](javascript:applyFixCode(2086)))
if ! test "$1"
[Line 13:](javascript:setPosition(13, 4))
if [[ $1 == "setup" ]]
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
[Line 20:](javascript:setPosition(20, 11))
if ! test $dlt
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([2])), apply [all SC2086](javascript:applyFixCode(2086)))
if ! test "$dlt"
[Line 27:](javascript:setPosition(27, 10))
larr=($line)
^-- [SC3030](https://www.shellcheck.net/wiki/SC3030) (warning): In POSIX sh, arrays are undefined.
^-- [SC2206](https://www.shellcheck.net/wiki/SC2206) (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
[Line 28:](javascript:setPosition(28, 11))
fname=${larr[0]}
^-- [SC3054](https://www.shellcheck.net/wiki/SC3054) (warning): In POSIX sh, array references are undefined.
[Line 29:](javascript:setPosition(29, 10))
furl=${larr[1]}
^-- [SC3054](https://www.shellcheck.net/wiki/SC3054) (warning): In POSIX sh, array references are undefined.
[Line 30:](javascript:setPosition(30, 14))
msysonly=${larr[2]}
^-- [SC3054](https://www.shellcheck.net/wiki/SC3054) (warning): In POSIX sh, array references are undefined.
[Line 31:](javascript:setPosition(31, 8))
if [[ $msysonly == 'msys-only' ]]
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
[Line 33:](javascript:setPosition(33, 8))
if [[ -z $MSYSTEM ]]
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
[Line 41:](javascript:setPosition(41, 14))
mkdir -p `dirname "$base_dir/$fname"`
^-- [SC2046](https://www.shellcheck.net/wiki/SC2046) (warning): Quote this to prevent word splitting.
^-- [SC2006](https://www.shellcheck.net/wiki/SC2006) (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean: ([apply this](javascript:applyFixIndex([11])), apply [all SC2006](javascript:applyFixCode(2006)))
mkdir -p $(dirname "$base_dir/$fname")
[Line 42:](javascript:setPosition(42, 10))
$dlt $furl $dlf $base_dir/$fname
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([12,13,14,15])), apply [all SC2086](javascript:applyFixCode(2086)))
$dlt "$furl" "$dlf" "$base_dir"/"$fname"
[Line 43:](javascript:setPosition(43, 7))
done <$assets_file
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([16])), apply [all SC2086](javascript:applyFixCode(2086)))
done <"$assets_file"
[Line 46:](javascript:setPosition(46, 4))
if [[ $1 == "build" ]]
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
[Line 48:](javascript:setPosition(48, 1))
cd $base_dir
^-- [SC2164](https://www.shellcheck.net/wiki/SC2164) (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([18,19])), apply [all SC2086](javascript:applyFixCode(2086)), apply [all SC2164](javascript:applyFixCode(2164)))
cd "$base_dir || exit"
[Line 56:](javascript:setPosition(56, 1))
read a
^-- [SC2162](https://www.shellcheck.net/wiki/SC2162) (info): read without -r will mangle backslashes.
^-- [SC2034](https://www.shellcheck.net/wiki/SC2034) (warning): a appears unused. Verify use (or export if used externally).
[Line 61:](javascript:setPosition(61, 4))
if [[ $OSTYPE == 'darwin'* ]]; then
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
^-- [SC3028](https://www.shellcheck.net/wiki/SC3028) (warning): In POSIX sh, OSTYPE is undefined.
[Line 64:](javascript:setPosition(64, 1))
cd build
^-- [SC2164](https://www.shellcheck.net/wiki/SC2164) (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Did you mean: ([apply this](javascript:applyFixIndex([24])), apply [all SC2164](javascript:applyFixCode(2164)))
cd build || exit
[Line 66:](javascript:setPosition(66, 1))
cd ..
^-- [SC2103](https://www.shellcheck.net/wiki/SC2103) (info): Use a ( subshell ) to avoid having to cd back.
[Line 73:](javascript:setPosition(73, 1))
cd build
^-- [SC2164](https://www.shellcheck.net/wiki/SC2164) (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Did you mean: ([apply this](javascript:applyFixIndex([26])), apply [all SC2164](javascript:applyFixCode(2164)))
cd build || exit
[Line 76:](javascript:setPosition(76, 4))
if [[ $OSTYPE == 'darwin'* ]]; then
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
^-- [SC3028](https://www.shellcheck.net/wiki/SC3028) (warning): In POSIX sh, OSTYPE is undefined.
[Line 77:](javascript:setPosition(77, 11))
$vmake -j $cpunum CC=gcc-12 CPP=g++-12 CXX=g++-12 LD=g++-12
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([29])), apply [all SC2086](javascript:applyFixCode(2086)))
$vmake -j "$cpunum" CC=gcc-12 CPP=g++-12 CXX=g++-12 LD=g++-12
[Line 79:](javascript:setPosition(79, 11))
$vmake -j $cpunum
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([30])), apply [all SC2086](javascript:applyFixCode(2086)))
$vmake -j "$cpunum"
[Line 82:](javascript:setPosition(82, 9))
if test $MSYSTEM
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([31])), apply [all SC2086](javascript:applyFixCode(2086)))
if test "$MSYSTEM"
[Line 86:](javascript:setPosition(86, 1))
cd ..
^-- [SC2103](https://www.shellcheck.net/wiki/SC2103) (info): Use a ( subshell ) to avoid having to cd back.
[Line 90:](javascript:setPosition(90, 1))
cd build
^-- [SC2164](https://www.shellcheck.net/wiki/SC2164) (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Did you mean: ([apply this](javascript:applyFixIndex([33])), apply [all SC2164](javascript:applyFixCode(2164)))
cd build || exit
[Line 96:](javascript:setPosition(96, 4))
if [[ $1 == "test" ]]
^-- [SC3010](https://www.shellcheck.net/wiki/SC3010) (warning): In POSIX sh, [[ ]] is undefined.
The script isn't supposed to support any shell other than bash.
So please use #!/bin/bash
shigure is actually a bash script but declared as
#!/bin/sh
, which will link to an installed POSIX-compatible shell. This works on BSD, macOS or ArchLinux since their default /bin/sh implementation is bash . However, on modern Debian-based distribution, the default /bin/sh implementation has switched to dash to improve performance. shigure use lots of non-POSIX syntax, such as arrays, which lead to crash on modern Debian and other people who use shell other than bash as /bin/sh implementation, so shigure should be declared as#!/bin/bash
instead of#!/bin/sh
.