bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Spaces trimmed from $* when assigned while IFS is unset [was: Unexpe


From: Greg Wooledge
Subject: Re: Spaces trimmed from $* when assigned while IFS is unset [was: Unexpected word splitting on $* ...]
Date: Wed, 27 Sep 2017 08:44:19 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Sep 27, 2017 at 05:50:16AM +0200, Martijn Dekker wrote:
> Test script:
> 
> set "  abc  " " def  ghi " "jkl "
> unset -v IFS var
> var=${var-$*}/${var-$*}
> printf '[%s]\n' "$var"

wooledg:~$ set "  abc  " " def  ghi " "jkl "
wooledg:~$ unset IFS

wooledg:~$ var="$*"; declare -p var
declare -- var="  abc    def  ghi  jkl "

wooledg:~$ unset var; var=${var-$*}; declare -p var
declare -- var="abc def ghi jkl"

wooledg:~$ unset var; var=${var-"$*"}; declare -p var
declare -- var="  abc    def  ghi  jkl "

I'm just going to chalk this up as yet another example of unquoted $*
or $@ being Completely Wrong.

Never use unquoted $* or address@hidden  It triggers all kinds of bugs (or
"differences in behavior across shells"), and has no conceivable
justification.  Always use "$@" or "$*".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]