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


Groups > gnu.bash.bug > #15434

Wildcard expansion can fail with nonprinting characters

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Geoff Kuenning <geoff@cs.hmc.edu>
Newsgroups gnu.bash.bug
Subject Wildcard expansion can fail with nonprinting characters
Date Fri, 27 Sep 2019 16:52:50 -0700
Lines 65
Approved bug-bash@gnu.org
Message-ID <mailman.2.1569634401.2651.bug-bash@gnu.org> (permalink)
References <pnih84x47ql.fsf@bow.cs.hmc.edu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1569634401 8574 209.51.188.17 (28 Sep 2019 01:33:21 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
User-Mail-Address geoff@cs.hmc.edu
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 134.173.42.59
X-Mailman-Approved-At Fri, 27 Sep 2019 21:33:19 -0400
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <pnih84x47ql.fsf@bow.cs.hmc.edu>
Xref csiph.com gnu.bash.bug:15434

Show key headers only | View raw


Version:

GNU bash, version 4.4.23(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>

Behavior:

If a pathname contains nonprinting characters, and is expanded 
from a variable name, wildcard expansion can sometimes fail.

Example (with actual nonprinting characters):

$ mkdir /tmp/test$'\361'dir
$ touch /tmp/test�dir/foo
$ ls /tmp/test�dir/f*
/tmp/test?dir/foo
$ x=/tmp/test�dir
$ echo "$x" | cat -v
/tmp/testM-qdir
$ ls "$x"/f*
ls: cannot access '/tmp/test'$'\361''dir/f*': No such file or 
directory

(Note: in the above example, I completed the "ls" line and 
generated x by using tab completion.  However, the bug happens 
even if the variable is set by other means, such as from the 
output of a script that generates the nonprinting pathname.)

Example repeated, with nonprinting character replaced with M-q in 
case mailers mangle them:

$ mkdir /tmp/test$'\361'dir
$ touch /tmp/testM-qdir/foo
$ ls /tmp/testM-qdir/f*
/tmp/test?dir/foo
$ x=/tmp/testM-qdir
$ echo "$x" | cat -v
/tmp/testM-qdir
$ ls "$x"/f*
ls: cannot access '/tmp/test'$'\361''dir/f*': No such file or 
directory

Expected behavior: ls with "$x/*" should list foo in both cases.

Observed behavior: when foo is accessed via variable substitution, 
the wildcard is not expanded.

Other comments: I've observed similar behavior with tab expansion 
and complex pathnames that contain "surprising" characters such as 
parentheses, spaces, and nonprinting characters, but I'm not sure 
whether it's related.
-- 
    Geoff Kuenning   geoff@cs.hmc.edu 
    http://www.cs.hmc.edu/~geoff/

The major difference between a thing that might go wrong and a 
thing
that cannot possibly go wrong is that when a thing that cannot
possibly go wrong goes wrong it usually turns out to be impossible 
to
get at or repair.
                -- Douglas Adams

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


Thread

Wildcard expansion can fail with nonprinting characters Geoff Kuenning <geoff@cs.hmc.edu> - 2019-09-27 16:52 -0700

csiph-web