On Wed, Jul 01, 2015 at 10:19:10PM +0300, Ilya Basin wrote:
> Hi list.
> 
> Want to read whole stdin into variable.
> Don't want to spawn new processes (cat).
> Don't want to reopen existing fd &0
> 
> First thing I tried: $(<&0)
> It silently returns an empty string.

This type of query is preferably asked at the help-bash list rather than
bug-bash.

 
>     # works, but too complex
>     [root@okdistr ~]# echo aaa | sudo -u nobody bash -c 'a=; while true; do 
> rc=0; read -N1024 b || rc=$?; a=$a$b; [ $rc = 0 ] || break; done; echo "$a"'
>     aaa

    IFS= read -rd '' a
    printf %s "$a"

Reply via email to