Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Greg Wooledge 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 10:19:01 -0400 Lines: 42 Approved: bug-bash@gnu.org Message-ID: References: <20180801130320.wwmnw6ixxztihj3i@eeg.ccf.org> <20180801121251.efyquoibrsneiqbl@eeg.ccf.org> <360e6d91-f959-ef2e-a349-9286542890b7@passchier.net> <22714.1533132320@jinx.noi.kre.to> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1533133155 5007 208.118.235.17 (1 Aug 2018 14:19:15 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: <22714.1533132320@jinx.noi.kre.to> 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14434 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 > set -- '*.c' '*.h' OK, let's run with that. wooledg:/tmp/x$ touch "file one.txt" file2.txt wooledg:/tmp/x$ set -- '*.txt' wooledg:/tmp/x$ args $* 2 args: At this point one may think, "Hey, this is actually working. That Greg guy doesn't know what he's talking about!" Now, what if we want to glob for the files that have spaces? Here's the glob that matches them: wooledg:/tmp/x$ args *\ * 1 args: So we should be able to put that glob in the positional parameter list and use your unquoted $* trick, right? wooledg:/tmp/x$ set -- '* *' wooledg:/tmp/x$ args $* 4 args: It's a disaster, as I said. It works ONLY IN THE STUPIDLY SIMPLE CASES and then falls apart as soon as you do anything more. Like putting spaces in the glob. Or setting IFS to the empty string. This is not a "hobby horse". This is real. And people wonder why I'm cranky all the time.