> > ksh93v- 2013-02-22 does not honor -r with -d ''.
> > Exemple:
> > 
> > ## correct behaviour with delim='\n'
> > ## expected ouput is \ \n
> > $ printf '\\\n' | read -r
> > $ printf '%s\n' "$REPLY" | od -c
> > 0000000   \  \n
> > 0000002
> > 
> > ## incorrect behaviour with delim='\0'
> > ## expected output is \ \0
> > $ printf '\\\000' | read -r -d ''
> > $ printf '%s\000' "$REPLY" | od -c
> > 0000000  \0
> > 0000001
> > 
> > Philippe Bergheaud
> > 
> 
> The problem is not with read.  The problem is the REPLY terminates with 
the
> 0 bytes.
> 
> The following should work:
>    typeset -bZ2 var
>    printf '\\\000' | read -r -d '' var
>    print -n -v var |  od -c
> 
> typeset -b stores binary data.  $var expands to the uuencoded value.
>    print -v var
> for a binary variable, outputs the value of the variable.
> Also, printf "%B" will output the contents without expanding it.
> 
> 
> David Korn
> [email protected]

I think the problem is with read. The man page says that read -r should 
handle '\' like a regular character.

Here are two examples involving only '\0' terminated strings. In my 
opinion, the length of REPLY should be one in both cases. 

REPLY should hold 'a' in the first case [it does], and '\' in the second 
case [it does not].

ftdemo:linux.i386/bin> printf 'a\000' | read -r -d '' 
ftdemo:linux.i386/bin> print ${#REPLY}
1
ftdemo:linux.i386/bin> printf '\\\000' | read -r -d ''
ftdemo:linux.i386/bin> print ${#REPLY} 
0

Philippe

_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to