bug-bash
[Top][All Lists]
Advanced

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

Re: read unexpected reads directory list


From: Filimonov Vadim
Subject: Re: read unexpected reads directory list
Date: Tue, 31 Mar 2015 19:24:09 +0300

 Hello, Greg!

Thank you. It's really my mistake, sorry.
Good explanation.

But I can't understand why
echo *
prints listing of directory?
31.03.2015, 19:06, "Greg Wooledge" <address@hidden>:

On Tue, Mar 31, 2015 at 06:04:53PM +0300, Filimonov Vadim wrote:

address@hidden:~/bashbug/bash-4.3$ read -u63 LINE <(echo "*")
 bash: read: `/dev/fd/63': not a valid identifier

You are missing a < sign here.  You probably wanted:

read LINE < <(echo "*")

It is not safe to assume that the <() will produce a reference to file
descriptor 63.  On many platforms, it won't even use /dev/fd/ at all,
but will instead use a named pipe.

Your command expands to

read -u63 LINE /dev/fd/63

Which produces the error message, as it tries to treat /dev/fd/63 as
a variable name to assign into.  However, before it runs into that
error, it has already read a "*" character from file descriptor 63
(since you told it to do that with -u63).  And that * character is now
in the variable named LINE.

 ... ;echo $LINE
 ABOUT-NLS aclocal.m4 alias.c alias.h alias.o array.c arrayfunc.c arrayfunc.h arrayfunc.o array.h array.o assoc.c assoc.h assoc.o AUTHORS bash bashansi.h bashbug bashhist.c bashhist.h bashhist.o bashintl.h bashjmp

You always want echo "$LINE" and *never* echo $LINE.

http://mywiki.wooledge.org/BashPitfalls#pf14

The * from $LINE was expanded because you failed to quote properly.


reply via email to

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