I'd like to have standard parameters, i.e., my minimum reproducible example is:
#!/usr/bin/zsh a=${1:a} printf 'a: "%s"\n' "${a}" b=${2:./build} printf 'b: "%s"\n' "${b}" I'd expect to see, when running ./demo.zsh without arguments:
a: "a" b: "./build" Instead I get
a: "" ./demo.zsh:4: bad floating point constant - why does
${1:a}seem to assume$1to be set and non-zero, but the$aexpanded is empty string? - where does the floating point misparsing come from? If I replace
./buildwithbuild, it complains aboutbbeing an unknown modifier.
If I run ./demo.zsh asdf bar, I get
a: "/tmp/fasf" ./demo.zsh:4: bad floating point constant which, frankly is even more confusing; where does /tmp/ come from (it's the cwd).
${1:-a}or${1-a}? Is your question about what actually happens in the nonstandard expansion of${1:a}?:-a. Time for another coffee. (an explanation of what happened there would still be welcome, but I don't want you to sink much time into that, I can look it up myself)