bug-bash
[Top][All Lists]
Advanced

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

Re: Unquoted array slice address@hidden:0} expands to just one word if I


From: Greg Wooledge
Subject: Re: Unquoted array slice address@hidden:0} expands to just one word if IFS doesn't have a space
Date: Wed, 1 Aug 2018 09:03:20 -0400
User-agent: NeoMutt/20170113 (1.7.2)

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 bug that wants fixing?
> That would be a very noble goal, should it not be possible?

Maybe, but for a script writer, it's already too late.  Unless you fast
forward 20-30 years into the future when EVERY shell has had these bugs
fixed for long enough that you can be reasonably confident that your
script will not be executed by one of the older shell versions.

Isn't it simpler just not to write buggy scripts in the first place?

"$@" expands to a list of words, and "$*" expands to a single string
with an optional single-character delimiter inserted between substrings.
Those are the only two options you've got.

What's the intent of a script that uses unquoted $@ or $*?  What did
the script's author think was going to happen?  If it's one of the two
cases above, then the missing quotes are simply a bug in the script.
If it's something else, then I'd be interested in hearing it.

I don't speak for Chet on any of these issues.  He may feel an obligation
to fix bash if he perceives the behavior as a bug.  That's independent
of whether a script writer should actually USE such syntax.



reply via email to

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