On Sun, Dec 11, 2022 at 08:06:24PM -0500, Rob Whitlock wrote:
> On line 408, fw_update has the expression ${LOCALSRC:#file:}. The parameter
> substitution ${name:#word} is not documented in the manual page for ksh yet
> its behavior seems to be equivalent to ${LOCALSRC#file:}. Assuming this is
> a typo, a patch is provided to remove the colon. If it is not a typo, could
> someone explain what this syntax does?

It was a typo, committed, thanks!


> Is this was a typo however, and this parameter substitution is not
> officially supported, why did ksh not complain?

Not having read it, I assume the implementation reads the : and sets a
flag that says "must be be NULL" for the -, +, =, and ? substitutions
and the validation that the next character is one of those four is
missing.

An email to bugs@ with this question might get the attention of folks
who are more familiar with ksh internals and whether fixing this being
too accepting is worth the code and the likelihood of breaking scripts
with typos like this one.


> Rob
> 
> diff --git usr.sbin/fw_update/fw_update.sh usr.sbin/fw_update/fw_update.sh
> index 4b77d4c7bd7..dbc80257228 100644
> --- usr.sbin/fw_update/fw_update.sh
> +++ usr.sbin/fw_update/fw_update.sh
> @@ -405,7 +405,7 @@ if [ "$LOCALSRC" ]; then
>                 FWURL="${LOCALSRC}"
>                 LOCALSRC=
>         else
> -               LOCALSRC="${LOCALSRC:#file:}"
> +               LOCALSRC="${LOCALSRC#file:}"
>                 ! [ -d "$LOCALSRC" ] &&
>                     echo "The path must be a URL or an existing directory"
> >&2 &&
>                     exit 1

Reply via email to