Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Chet Ramey
On 8/1/18 10:52 AM, Robert Elz wrote: > Date:Wed, 1 Aug 2018 09:40:12 -0400 > From:Greg Wooledge > Message-ID: <20180801134012.r6ojiewtx3npa...@eeg.ccf.org> > > | https://lists.gnu.org/archive/html/bug-bash/2017-06/msg00283.html > > A bug in dash which as far as I

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Robert Elz
Date:Wed, 1 Aug 2018 09:40:12 -0400 From:Greg Wooledge Message-ID: <20180801134012.r6ojiewtx3npa...@eeg.ccf.org> | https://lists.gnu.org/archive/html/bug-bash/2017-06/msg00283.html A bug in dash which as far as I can tell has since been fixed. | https://lists.gn

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Greg Wooledge
On Wed, Aug 01, 2018 at 09:05:20PM +0700, Robert Elz wrote: > Date:Wed, 1 Aug 2018 09:03:20 -0400 > From:Greg Wooledge > | What's the intent of a script that uses unquoted $@ or $*? > > Either (or both) of field splitting of the args, or filename expansion. > > As in >

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Robert Elz
Date:Wed, 1 Aug 2018 09:03:20 -0400 From:Greg Wooledge Message-ID: <20180801130320.wwmnw6ixxztih...@eeg.ccf.org> | "$@" expands to a list of words, and "$*" expands to a single string | with an optional single-character delimiter inserted between substrings. | T

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Greg Wooledge
On Wed, Aug 01, 2018 at 04:06:03PM +0300, Ilkka Virta wrote: > Unquoted $* seems well-defined in Bash's reference manual: > > ($*) Expands to the positional parameters, starting from one. When the > expansion is not within double quotes, each positional parameter > expands to a separate word

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Ilkka Virta
On 1.8. 15:12, Greg Wooledge wrote: On Wed, Aug 01, 2018 at 02:43:27PM +0300, Ilkka Virta wrote: On both Bash 4.4.12(1)-release and 5.0.0(1)-alpha, a subarray slice like ${a[@]:0} expands to just one word if unquoted (and if IFS doesn't contain a space): This just reinforces the point that unq

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Greg Wooledge
On Wed, Aug 01, 2018 at 07:42:30PM +0700, pepa65 wrote: > On 08/01/2018 07:12 PM, Greg Wooledge wrote: > > This just reinforces the point that unquoted $@ or $* (or the array > > equivalent) is a bug in the script. It gives unpredictable results. > > If the results are unpredictable, isn't that a

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread pepa65
On 08/01/2018 07:12 PM, Greg Wooledge wrote: > This just reinforces the point that unquoted $@ or $* (or the array > equivalent) is a bug in the script. It gives unpredictable results. If the results are unpredictable, isn't that a bug that wants fixing? That would be a very noble goal, should it

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Greg Wooledge
On Wed, Aug 01, 2018 at 02:43:27PM +0300, Ilkka Virta wrote: > On both Bash 4.4.12(1)-release and 5.0.0(1)-alpha, a subarray slice like > ${a[@]:0} expands to just one word if unquoted (and if IFS doesn't > contain a space): This just reinforces the point that unquoted $@ or $* (or the array equiv

Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Ilkka Virta
On both Bash 4.4.12(1)-release and 5.0.0(1)-alpha, a subarray slice like ${a[@]:0} expands to just one word if unquoted (and if IFS doesn't contain a space): $ a=(aa bb); IFS=x; printf ":%s:\n" ${a[@]:0} :aa bb: I expected it would expand to separate words, as it does without the slice, and ju