bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: substitution "read all from fd" silently fails: $(<&0)


From: Geir Hauge
Subject: Re: substitution "read all from fd" silently fails: $(<&0)
Date: Wed, 1 Jul 2015 23:16:03 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

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
>     address@hidden ~]# 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

[Prev in Thread] Current Thread [Next in Thread]