[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: IFS field splitting doesn't conform with POSIX
From: |
Felipe Contreras |
Subject: |
Re: IFS field splitting doesn't conform with POSIX |
Date: |
Thu, 30 Mar 2023 10:51:58 -0600 |
On Thu, Mar 30, 2023 at 10:10 AM Oğuz İsmail Uysal
<oguzismailuysal@gmail.com> wrote:
>
> On 3/30/23 2:12 PM, Felipe Contreras wrote:
> > IFS=,
> > str='foo,bar,,roo,'
> > printf '"%s"\n' $str
> zsh is the only shell that generates an empty last field, no other shell
> exhibits this behavior.
So? This is argumentum ad populum. The fact that most shells do X
doesn't imply that POSIX says X.
It could very well mean that all shells are implementing POSIX wrong.
Except zsh.
Or it could mean POSIX doesn't specify which behavior is correct.
> Besides your link says:
> >The shell shall treat each character of the IFS as a delimiter and use
> the delimiters as *field >terminators* to split the results of parameter
> expansion, command substitution, and arithmetic >expansion into fields.
>
> So the delimiters terminate fields, not separate them.
Yes. 'foo,bar,' has two terminators, and therefore two fields.
'foo,bar,roo' has two terminators and therefore two fields, plus
garbage.
You want to interpret 'foo' as a field, even though it does not have
an an explicit terminator. But that's not specified anywhere in POSIX.
POSIX doesn't say what should be done with the text after the last
terminator. You could throw it away and still be conforming to POSIX.
--
Felipe Contreras
- Re: IFS field splitting doesn't conform with POSIX, (continued)
- Re: IFS field splitting doesn't conform with POSIX, Greg Wooledge, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Kerin Millar, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Felipe Contreras, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Greg Wooledge, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Kerin Millar, 2023/03/30
Re: IFS field splitting doesn't conform with POSIX, Oğuz İsmail Uysal, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX,
Felipe Contreras <=
- Re: IFS field splitting doesn't conform with POSIX, Andreas Kusalananda Kähäri, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Oğuz İsmail Uysal, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Felipe Contreras, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Lawrence Velázquez, 2023/03/30
- Re: IFS field splitting doesn't conform with POSIX, Chet Ramey, 2023/03/31
Re: IFS field splitting doesn't conform with POSIX, Andreas Schwab, 2023/03/30
Re: IFS field splitting doesn't conform with POSIX, Chet Ramey, 2023/03/31
Re: IFS field splitting doesn't conform with POSIX, Chet Ramey, 2023/03/31
IFS field splitting doesn't conform with POSIX, Felipe Contreras, 2023/03/30