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

Re: funny behaviour of print



On Tue, Mar 02, 1999 at 09:23:44PM -0500, Sweth Chandramouli wrote:
# 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

But if you look, you'll see it accepts any number of dashes.  Which I
find rather silly.

# 	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'.)

:)  a bit of a pain for a solution.  Just have to use
print -- $CTAGS
as that works.

I still would like to know if this is a bug or a 'feature'. :>



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