Path: csiph.com!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 09:03:20 -0400 Lines: 28 Approved: bug-bash@gnu.org Message-ID: References: <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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14430 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.