[prev in list] [next in list] [prev in thread] [next in thread]
List: ast-users
Subject: Re: [ast-users] ksh echo builtin
From: David Korn <dgk () research ! att ! com>
Date: 2010-11-15 16:50:51
Message-ID: 201011151650.oAFGoppM029776 () penguin ! research ! att ! com
[Download RAW message or body]
Subject: Re: [ast-users] ksh echo builtin
--------
> Hi,
>
> I've just tested some script, because I've heard some complains that it takes
> too much time with bash. I did a small benchmark and it was working great.
> bash: 2:49
> zsh: does not work
> mksh: 1:35
> ksh: 0:35
>
> unfortunatelly ksh produced wrong output. The problem was with
> echo -e "\x${VAL}"
> seems ksh echo builtin does not support \xNN. In man page there is:
> > When the first arg does not begin with a -, and none of the arguments
> > contain a \, then echo prints each of its arguments separated by a space
> > and terminated by a new-line. Otherwise, the behavior of echo is system
> > dependent and print or printf described below should be used. See
> > echo(1) for usage and description.
>
> what does mean "system dependent"? ksh's echo does not behave always the same
> way?
>
What the standard means that if you use echo and the first argument is -
or any argument contains a \, you cannot count on what the behavior will be.
ksh93 recognizes -n and -e and treates any other value as operands.
The -n means don't add a new-line.
The -e means emulate system V echo. The system V echo supported
backslash sequences, but not \Xnn. It supported octal sequences.
A better bet is to use printf whose behavior is well defined by the
standard.
printf "\x${VAL}\n"
whould work with all standard shells.
David Korn
dgk@research.att.com
_______________________________________________
ast-users mailing list
ast-users@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic