Subject: Re: [ksh93-integration-discuss] CR 6977405 Created,  P4 shell/korn93 
ksh93 script has problem with newline
--------

> === *Description* ============================================================
> Such simple script like:
> 
> #!/bin/sh
> 
> set -vx
> COMMAND="/usr/bin/echo 
> -d passwd"
> 
> echo "$COMMAND"
> 
> 
> has very strange output:
> 
> $ ./testbug.sh 
> COMMAND="/usr/bin/echo 
> -d passwd"
> 
> + COMMAND=$'/usr/bin/echo \n-d passwd'
> echo "$COMMAND"
> + echo $'/usr/bin/echo \n-d passwd'
> /usr/bin/echo 
> -d passwd
> 
> 
> "$'/usr/bin/echo \n-d passwd' is different from other shells and it is used 
> only
>  in case that there is newline (and other shells probably).
> 
> From ksh93 FAQ:
> 
> Q5.   What is the purpose of $'...'?
> A5.   The $'...' option was added to ksh93 to solve the problem
>       of entering special characters in scripts.  It uses
>       ANSI-C rules to translate the string between the '...'.
>       It would have been cleaner to have all "..." strings handle
>       ANSI-C escapes, but that would not be backwards compatible.
> 
> 
> Well, this is incompatible with other shells, misleading and awkward.
> 
> *** (#1 of 1): 2010-08-16 15:42:38 GMT+00:00 <User 1-1SURPB>
> 
> 
> === *Public Comments* ========================================================
> 
> 

I don't see or understand what the problem is.

ksh93 is a reflexive language.  As much as possible, the output format is
in a form that can be reinput.  To avoid confusion, ksh93 uses the $'...'
on output knowing that it can be copied back as input.

There reflexive nature of ksh93 can be see with variabesl (including compound
variables) and types for which  which.

        typeset -p > file
produces a file you you can do
        . file
and get back all the variables and attributes (except readonly).

I don't know what other shells offer this, but this is an important feature
for ksh93.

David Korn
d...@research.att.com
_______________________________________________
ksh93-integration-discuss mailing list
ksh93-integration-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/ksh93-integration-discuss

Reply via email to