Open thomasmerz opened 2 years ago
@cleanbrowsing , have you seen my PR and can you please review and merge it? Thanks…
@cleanbrowsing , I rebased this PR and shellcheck
'ed some more style-warnings that came from some other PRs:
SC2181 (style): Check exit code directly with e.g. 'if mycmd;', not indirectly with $? SC2268 (style): Avoid x-prefix in comparisons as it no longer serves a purpose.
Testing dnstest.sh
after I shellcheck
'ed it:
The issue with this syntax is that it breaks on openbsd's default shell (the standard sh shell - openbsd user here). For example, this is what I get when I run with the changes:
./dnstest.sh: syntax error: `< ' unexpected
That's why I kept the "x$1" syntax and the "if [ $?" format to test for the command results. Not sure what can be done to make it compatible with the standard sh shells and remove this format.
Quick way to test:
$ ./test.sh
./test.sh[5]: [: test: unexpected operator/operand
file:
#!/bin/sh
if [ $1 = "test" ]; then
echo "cmd1 = test"
fi
If I change to:
$ cat test.sh
#!/bin/sh
if [ "x$1" = "xtest" ]; then
echo "cmd1 = test"
fi
It works:
$ ./test.sh
$ ./test.sh test
cmd1 = test
Using OpenBSD 6.9
I added a commit to fix your problem with openbsd's default shell. But I wonder, if shebang says "use bash" why openbsd is ignoring this and uses default shell (that is not bash?) 🤔 …
Thanks! Checking that now.
Ping @cleanbrowsing …
Ping @cleanbrowsing …
Before:
After no complains anymore 👍🏻