bug-bash
[Top][All Lists]
Advanced

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

Re: Empty trailing fields ignored by read


From: DJ Mills
Subject: Re: Empty trailing fields ignored by read
Date: Thu, 29 Aug 2013 15:38:56 -0400

On Thu, Aug 29, 2013 at 2:54 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:

> On Thu, Aug 29, 2013 at 12:57:22PM -0400, DJ Mills wrote:
> > On Thu, Aug 29, 2013 at 12:42 PM, DJ Mills <danielmills1@gmail.com>
> wrote:
> >
> > > When using a non-default IFS (a default IFS would trim them), a single
> > > empty trailing field is ignored for read -a.
> > >
> > > IFS=: read -rd '' -a arr < <(printf %s ':foo:bar:'); printf '<%s> '
> > > "${arr[@]}"; echo
> > > <> <foo> <bar>
> > >
> > > I would expect the output to be:
> > > <> <foo> <bar> <>
>
> Looks like:
> http://lists.gnu.org/archive/html/bug-bash/2008-02/msg00056.html
>
> There may be other occurrences.  I seem to recall something more recent
> than 2008.
>

That's a different issue, and in that case makes sense. It's the same
reason that
when reading a file with no trailing newline, read will exit > 0 for the
last line.

In this case, the exit status is irrelevant. In fact, I expect it to exit >
0, as there's no
NUL byte in the input. However, with or without -d, the last field is
completely ignored.


reply via email to

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