bug-bash
[Top][All Lists]
Advanced

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

bash Fails Glob Though No Glob Present.


From: Ralph Corderoy
Subject: bash Fails Glob Though No Glob Present.
Date: Fri, 15 Mar 2019 14:23:01 +0000

Hi,

bash 5.0.0-1 on Arch Linux.  I'm manipulating a variable that's intended
to hold a regular expression for vim(1), but bash thinks it fails
pathname expansion even though I see no glob meta-character within it.

    $ shopt -s failglob
    $ ls -d foo
    ls: cannot access 'foo': No such file or directory
    $ ls foo/bar
    ls: cannot access 'foo/bar': No such file or directory
    $ ls foo\/bar
    ls: cannot access 'foo/bar': No such file or directory

That's all as expected.  I can escape the / and it remains a /.

    $ s='foo\/bar'

Single quotes ensure $s contains the two characters \ then /.

    $ ls "$s"
    ls: cannot access 'foo\/bar': No such file or directory

The \/ is preserved, as shown by ls's error.

    $ ls $s
    -bash: no match: foo\/bar
    $

Without the protection of the double-quotes, bash does pathname
expansion, but it doesn't contain a *, ?, or [ as listed under `Pathname
Expansion' in bash(1).

-- 
Cheers, Ralph.



reply via email to

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