Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Geoff Kuenning 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: References: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com gnu.bash.bug:15434 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=20 Behavior: If a pathname contains nonprinting characters, and is expanded=20 from a variable name, wildcard expansion can sometimes fail. Example (with actual nonprinting characters): $ mkdir /tmp/test$'\361'dir $ touch /tmp/test=EF=BF=BDdir/foo $ ls /tmp/test=EF=BF=BDdir/f* /tmp/test?dir/foo $ x=3D/tmp/test=EF=BF=BDdir $ echo "$x" | cat -v /tmp/testM-qdir $ ls "$x"/f* ls: cannot access '/tmp/test'$'\361''dir/f*': No such file or=20 directory (Note: in the above example, I completed the "ls" line and=20 generated x by using tab completion. However, the bug happens=20 even if the variable is set by other means, such as from the=20 output of a script that generates the nonprinting pathname.) Example repeated, with nonprinting character replaced with M-q in=20 case mailers mangle them: $ mkdir /tmp/test$'\361'dir $ touch /tmp/testM-qdir/foo $ ls /tmp/testM-qdir/f* /tmp/test?dir/foo $ x=3D/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=20 directory Expected behavior: ls with "$x/*" should list foo in both cases. Observed behavior: when foo is accessed via variable substitution,=20 the wildcard is not expanded. Other comments: I've observed similar behavior with tab expansion=20 and complex pathnames that contain "surprising" characters such as=20 parentheses, spaces, and nonprinting characters, but I'm not sure=20 whether it's related. --=20 Geoff Kuenning geoff@cs.hmc.edu=20 http://www.cs.hmc.edu/~geoff/ The major difference between a thing that might go wrong and a=20 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=20 to get at or repair. -- Douglas Adams