Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: src
> Module Name: src
> Committed By: kre
> Date: Fri Dec 20 22:24:20 UTC 2024
>
> Modified Files:
> src: build.sh
>
> Log Message:
> General code cleanup. No operational change intended.
>
> Mostly fix quoting, some missing quotes added, lots of meaningless
> quotes removed (no guarantee of completeness in either of those).
> [...]
> - local prog="$1"
> - local result="${2-"$1"}"
> - local oldIFS="${IFS}"
> + local prog=$1
> + local result=${2-$1}
It's possible that in context this is safe because of limits on the
possible arguments (I didn't read that far to see), but I find the
syntax of `local x=y' syntax to be a sharp edge because it works
differently from `x=y'. In particular:
$ (foo() { local x=$1; echo $x; }; foo "123 456")
local: 456: bad variable name
123
$ (foo() { local x="$1"; echo $x; }; foo "123 456")
123 456
$ (foo() { local x; x=$1; echo $x; }; foo "123 456")
123 456
So I think it is better style in shell scripts to either consistently
write
local x="$1"
with the quotes, or separate the local and the assignment:
local x
x=$1
(That said, I agree that the inner quotes in "${2-"$1"}" were silly
and replacing it by local result="${2-$1}" is fine.)
Home |
Main Index |
Thread Index |
Old Index