Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Andreas Schwab
On Mär 30 2023, Felipe Contreras wrote: > On Thu, Mar 30, 2023 at 10:10 AM Oğuz İsmail Uysal > 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

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Lawrence Velázquez
On Thu, Mar 30, 2023, at 2:25 PM, Felipe Contreras wrote: > On Thu, Mar 30, 2023 at 11:48 AM Oğuz İsmail Uysal > wrote: >> >> On 3/30/23 7:51 PM, Felipe Contreras wrote: >> > So? This is argumentum ad populum. The fact that most shells do X >> > doesn't imply that POSIX says X. > >> POSIX

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Kerin Millar
On Thu, 30 Mar 2023 11:52:06 -0600 Felipe Contreras wrote: > Chet wrote: > > Alternately, you can think of the NUL at the end of the string as an > > additional field terminator, > > Except if you do that, then 'a,' has two fields since the end of the > string is an additional field terminator,

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
On Thu, Mar 30, 2023 at 11:48 AM Oğuz İsmail Uysal wrote: > > On 3/30/23 7:51 PM, Felipe Contreras wrote: > > So? This is argumentum ad populum. The fact that most shells do X > > doesn't imply that POSIX says X. > POSIX documents existing practice. Your definition of what a standard is and

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Greg Wooledge
On Thu, Mar 30, 2023 at 11:52:06AM -0600, Felipe Contreras wrote: > Not to mention the small detail that the Internal Field Separator is > not a *separator*, but a terminator (with certain exceptions). POSIX itself admits that the name is confusing. From sh(1posix): RATIONALE [...]

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
On Thu, Mar 30, 2023 at 11:22 AM Kerin Millar wrote: > > On Thu, 30 Mar 2023 07:51:59 -0600 > Felipe Contreras wrote: > > > On Thu, Mar 30, 2023 at 5:23 AM Greg Wooledge wrote: > > > > > > On Thu, Mar 30, 2023 at 05:12:46AM -0600, Felipe Contreras wrote: > > > > IFS=, > > > >

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Emanuele Torre
On Thu, Mar 30, 2023 at 11:35:08AM -0600, Felipe Contreras wrote: > > How can you say that the current implementation that bash, dash, etc. > > use is not compliant to the POSIX specification? > > I have never said that. The title of this thread is "IFS field splitting doesn't conform with

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Oğuz İsmail Uysal
On 3/30/23 7:51 PM, Felipe Contreras wrote: So? This is argumentum ad populum. The fact that most shells do X doesn't imply that POSIX says X. POSIX documents existing practice. If what it says differs from what the majority of shells do, then it's POSIX that is wrong. And this mailing list

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
On Thu, Mar 30, 2023 at 9:52 AM Emanuele Torre wrote: > > On Thu, Mar 30, 2023 at 07:51:59AM -0600, Felipe Contreras wrote: > > But you can't replicate 'a,b' that way, because b does not have a > > terminator. Obviously we'll want 'b' as a field, therefore one has to > > assume either 1) the end

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Andreas Kusalananda Kähäri
On Thu, Mar 30, 2023 at 10:51:58AM -0600, Felipe Contreras wrote: > On Thu, Mar 30, 2023 at 10:10 AM Oğuz İsmail Uysal > 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

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Kerin Millar
On Thu, 30 Mar 2023 07:51:59 -0600 Felipe Contreras wrote: > On Thu, Mar 30, 2023 at 5:23 AM Greg Wooledge wrote: > > > > On Thu, Mar 30, 2023 at 05:12:46AM -0600, Felipe Contreras wrote: > > > IFS=, > > > str='foo,bar,,roo,' > > > printf '"%s"\n' $str > > > > > > There is a

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
On Thu, Mar 30, 2023 at 10:10 AM Oğuz İsmail Uysal 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

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Oğuz İsmail Uysal
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. Besides your link says: >The shell shall treat each character of the IFS as a delimiter

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Emanuele Torre
On Thu, Mar 30, 2023 at 07:51:59AM -0600, Felipe Contreras wrote: > But you can't replicate 'a,b' that way, because b does not have a > terminator. Obviously we'll want 'b' as a field, therefore one has to > assume either 1) the end of the string is considered an implicit > terminator, or 2) the

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
On Thu, Mar 30, 2023 at 5:23 AM Greg Wooledge wrote: > > On Thu, Mar 30, 2023 at 05:12:46AM -0600, Felipe Contreras wrote: > > IFS=, > > str='foo,bar,,roo,' > > printf '"%s"\n' $str > > > > There is a discrepancy between how this is interpreted between bash > > and zsh: in bash the

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread alex xmb ratchev
how spooky , cant get read / mapfile to separate right very sad On Thu, Mar 30, 2023, 15:19 Felipe Contreras wrote: > Hi, > > Consider this example: > > IFS=, > str='foo,bar,,roo,' > printf '"%s"\n' $str > > There is a discrepancy between how this is interpreted between bash > and

IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
Hi, Consider this example: IFS=, str='foo,bar,,roo,' printf '"%s"\n' $str There is a discrepancy between how this is interpreted between bash and zsh: in bash the last comma doesn't generate a field and is ignored, in zsh a last empty field is generated. Initially I was going to

Re: IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Greg Wooledge
On Thu, Mar 30, 2023 at 05:12:46AM -0600, Felipe Contreras wrote: > IFS=, > str='foo,bar,,roo,' > printf '"%s"\n' $str > > There is a discrepancy between how this is interpreted between bash > and zsh: in bash the last comma doesn't generate a field and is > ignored, ... which is

IFS field splitting doesn't conform with POSIX

2023-03-30 Thread Felipe Contreras
Hi, Consider this example: IFS=, str='foo,bar,,roo,' printf '"%s"\n' $str There is a discrepancy between how this is interpreted between bash and zsh: in bash the last comma doesn't generate a field and is ignored, in zsh a last empty field is generated. Initially I was going to