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

Re: funny behaviour of print



On Tue, Mar 02, 1999 at 07:29:48PM -0500, Gabor Egressy wrote:
> I get weird behaviour with print.  If I print a variable which is
> something like below, I get a complaint from it.
> 
> === $ echo $CTAGS
> --langmap=c:.c.ec.y.l --c-types=cdefgmnstuvx --kind-long=yes
> === $ print $CTAGS
> zsh: bad option: -a
> zsh: exit 1
> === $ print --------l hello world
> hello
> world
> === $ 

	i don't get the exit 1 running zsh 3.1.5, but otherwise
i've seen the same behaviour.  two things seem odd about it.
	a) echo assumes that if the first "flag" seen isn't
valid then no flags were intended (and instead interprets the
"flags" as arguments to be echoed), while print assumes that if
the first "flag" seen isn't valid then it was passed a list of
invalid flags, and complains; and
	b) echo does not accept flags after a double-hyphen, whereas
print does:
(astaroth/1909)~: echo -e bob
bob
(astaroth/1910)~: echo --e bob
--e bob
(astaroth/1911)~: print -l bob
bob
(astaroth/1912)~: print --l bob
bob

	i guess the immediate workaround would be to alias the builtins
so that flags were explicitly ignored, with something like 
$ alias echo='echo -' ; alias print='print -' 
	(if you wanted to set any flags, of course, you would have to
then do a `builtin print' or `builtin echo'.)

	-- sweth.

-- 
Sweth Chandramouli
IS Coordinator, The George Washington University
<sweth@xxxxxxx> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html";>*</a>



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