Mail Archives: cygwin/2009/04/22/08:24:53
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Ken Brown on 4/22/2009 5:58 AM:
>> It is maybe getting globbed on the command-line because not
>> protected by
>> quoting and it contains pattern match chars?
>
> The text in question is in the definition of _known_hosts() in
> /etc/bash_completion, in case someone wants to try to sort this out.
Which looks like:
COMPREPLY=($( awk 'BEGIN {FS=","}
/^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
gsub(" .*$", "", $i); \
if ($i ~ /'$cur'/) {print $i} \
}}' "${kh[@]}" 2>/dev/null ));
That looks properly quoted to me. Really, the question is why does awk
call stat() on its first argument? Here's a simpler test case:
$ echo hi > hi
$ strace -o trace.txt gawk '{ print }' hi
The strace is informative:
110 40766 [main] gawk 2804 build_argv: argv[0] = 'gawk'
453 41219 [main] gawk 2804 lstat64: entering
79 41298 [main] gawk 2804 normalize_posix_path: src { print }
...
37 42339 [main] gawk 2804 stat_worker: -1 = (\??\K:\cygwin-2\tmp\{
print }, 0x1DCB18)
96 42435 [main] gawk 2804 globify: argv[1] = '{ print }'
65 42500 [main] gawk 2804 build_argv: argv[2] = 'hi'
35 42535 [main] gawk 2804 build_argv: argc 3
with no further references to '{ print }' once awk is running.
In other words, the problematic stat is occurring prior to main(), and it
is not awk's fault, but rather cygwin's, that globify() is trying to
dereference a non-file name and triggering the warning. Even the presence
of { in a command line argument was enough to trigger globify(). But
maybe that is an artifact of strace. Notice the difference between:
$ ls '*'
ls: cannot access *: No such file or directory
$ strace -o trace.txt ls '*'
hi trace.txt
$
In other words, strace is mistakenly performing glob expansion on the
subsidiary arguments to the program being traced, when we really wanted to
trace ls with a literal argument of "*".
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknvDG0ACgkQ84KuGfSFAYAmwgCeLrHqXzoge9i7hg4YDYoqkLIr
4YoAmwYjq9aYiYXDirAVYkfo93kk3B4Y
=fu91
-----END PGP SIGNATURE-----
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -