Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Discrepancy in IFS handling (zsh is POSIX compliant)



On Mar 30, 2023, at 7:13 AM, Felipe Contreras <felipe.contreras@xxxxxxxxx> wrote:

However, this is what POSIX says:

   3.b. Each occurrence in the input of an IFS character that is not
IFS white space, along with any adjacent IFS white space, shall
delimit a field, as described previously.

We ignore all the white space stuff (since we are not using white
spaces), and thus:

   Each occurrence in the input of an IFS character shall delimit a field.

In zsh each occurrence of a comma does delimit a field (4 commas, 5
fields), which to me is what POSIX says should happen.

So in this particular case it seems zsh is complying with POSIX (even
in zsh mode), and all other shells are not.

Before the excerpt you quoted, XCU 2.6.5 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.”

The bash/dash/ksh behavior is not unreasonable if the phrase “field terminators” is interpreted strictly.

In any case, I believe the standard intends to describe the ksh behavior:

-- 
vq
Sent from my iPhone


Messages sorted by: Reverse Date, Date, Thread, Author