Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14430

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

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space
Date Wed, 1 Aug 2018 09:03:20 -0400
Lines 28
Approved bug-bash@gnu.org
Message-ID <mailman.4549.1533128642.1292.bug-bash@gnu.org> (permalink)
References <c1978119-1836-e88d-4889-c54bea4d0559@iki.fi> <20180801121251.efyquoibrsneiqbl@eeg.ccf.org> <360e6d91-f959-ef2e-a349-9286542890b7@passchier.net>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1533128643 3075 208.118.235.17 (1 Aug 2018 13:04:03 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Mail-Followup-To bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <360e6d91-f959-ef2e-a349-9286542890b7@passchier.net>
User-Agent NeoMutt/20170113 (1.7.2)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 139.137.100.1
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14430

Show key headers only | View raw


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.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-01 09:03 -0400

csiph-web