[Swan-dev] please use more double quotes in shell scripts!
Andrew Cagney
andrew.cagney at gmail.com
Wed Jul 25 16:18:36 UTC 2018
> -webdir=$(cd $(dirname $0) && pwd)
> +webdir="$(cd "$(dirname $0)" && pwd)"
Actually, no. In this context, the outer quotes are not needed and
should not be used. When this was was explained to me, it came with
the phrase common beginner's mistake :-). I'm still fixing my
scripts:
charlie$ x="a b c" # needed
charlie$ echo "${x}"
a b c
charlie$ y=$x # not needed
charlie$ echo "${y}"
a b c
charlie$ z=$(echo "${y}")
charlie$ echo "${z}"
a b c
charlie$ echo $SHELL
/bin/sh
As for the inner quote, if someone has spaces in a directory path then
this is the least of their problems so I'm not fussed.
More information about the Swan-dev
mailing list