Subject: Re: [ast-users] ksh93v- read bug
--------

> 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]
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to