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

Re: read & leading (and trailing) spaces



On Tue, 12 May 2009, Bart Schaefer wrote:

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.)
================

my interpretation of "raw" would mean "output is _identical_ to input". should i apply a different interpretation to the read builtin?


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

if all of the other shells jumped off a bridge, would zsh jump too? SH_WORD_SPLIT is a good example of all the ~other~ shells being broken and zsh doing The Right Thing(tm) by default.


} 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.
==================

as long as i can work around it. thanks...


--
        ...atom

 ________________________
 http://atom.smasher.org/
 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
 -------------------------------------------------

	"... we must counterpose the overwhelming judgment provided
	 by consistent observations and inferences by the thousands.
	 The earth is billions of years old and its living creatures
	 are linked by ties of evolutionary descent. Scientists stand
	 accused of promoting dogma by so stating, but do we brand
	 people illiberal when they proclaim that the earth is neither
	 flat nor at the center of the universe? Science *has* taught
	 us some things with confidence! Evolution on an ancient earth
	 is as well established as our planet's shape and position.
	 Our continuing struggle to understand how evolution happens
	 (the 'theory of evolution') does not cast our documentation
	 of its occurrence -- the 'fact of evolution' -- into doubt."
		-- Stephen Jay Gould, "The Verdict on Creationism",
		The Skeptical Inquirer, Vol. XII No. 2.



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