Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11429

Re: Please take a look at this bug

From Ángel González <angel@16bits.net>
Newsgroups gnu.bash.bug
Subject Re: Please take a look at this bug
Date 2015-08-23 18:10 +0200
Message-ID <mailman.133.1440346250.11330.bug-bash@gnu.org> (permalink)
References <CADo71XMxMFh7y+gp6SGdHsG9Z9_2dfy4UN2K581E2MseAQxJ2w@mail.gmail.com>

Show all headers | View raw


Mostafa Nazari wrote:
> bug_part <(echo "TEST")

The <(echo "TEST") construct creates a pipe. You can view it just
printing the value that gets passed to the program:
$ echo <(echo "TEST")
/dev/fd/63

Now, a problem of that pipe is that the contents can only be read once.
Indeed, what would the second read do? Run echo "TEST" again? Should
the full file be stored in a temporary file "just in case you want to
read it again"? What you are trying to do is not supported.

It has some benefits, too. For instance:
$ function foo() { head -c 2 $1 > /tmp/a; head -c 2 $1 > /tmp/b; }
$ foo <(echo TEST)
will store "TE" in /tmp/a and "ST" in /tmp/b, as it's not rewinded.

Also note that other devices like tapes or sockets also have this "you
can only read once" limitation.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Please take a look at this bug Ángel González <angel@16bits.net> - 2015-08-23 18:10 +0200

csiph-web