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

Re: read & leading (and trailing) spaces



On May 12,  7:40pm, Atom Smasher wrote:
}
} this doesn't work as advertised when the input includes leading and/or 
} trailing spaces:
}  	read -r foo ; print -r -- "${foo}"

As advertised where?  The doc is silent on the treatment of leading and
trailing spaces; under -r, it says only that backslashes aren't special.

(The doc probably *shouldn't* be silent but that's another matter.)

I think you'll find that "read" in ksh, bash, etc. also removes leading
and trailing IFS characters, even with -r.

} i can work around that by setting IFS to either null (IFS='') or setting 
} it to just a newline (IFS='
} '). should i expect problems (in older or newer versions of zsh) using 
} either of those tricks to make read recognize leading/trailing spaces?

You should not expect problems with that, it's standard IFS behavior.



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