help-bash
[Top][All Lists]
Advanced

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

Re: printf '%s\n' "$@" versus <<< redirection


From: Kerin Millar
Subject: Re: printf '%s\n' "$@" versus <<< redirection
Date: Sun, 19 Feb 2023 17:09:30 +0000

On Sun, 19 Feb 2023 12:01:20 -0500
Greg Wooledge <greg@wooledge.org> wrote:

> On Sun, Feb 19, 2023 at 04:07:40PM +0000, Kerin Millar wrote:
> > I'll have a go at explaining it. Looking at 
> > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html, a 
> > particular behaviour is described for the case where the number of fields 
> > ends up being greater than the number of specified names, affecting the 
> > second, fourth and sixth of your test cases.
> > 
> > > 
> > > unicorn:~$ printf 'n\n' | { IFS='\n' read -r vl; declare -p vl; } 
> > > declare -- vl=""
> > 
> > There is one "n"-terminated field, matching the number of specified names. 
> > Its value is "", which is assigned.
> 
> Ugh!  It's pitfall 47 again.
> 
> https://mywiki.wooledge.org/BashPitfalls#pf47
> 
> No matter how many times I run into this, I never remember.  Because it
> MAKES NO SENSE.

Ah. Conversely, I forgot that there was anything concerning the matter in the 
wiki.

-- 
Kerin Millar



reply via email to

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