Bash – Configure bash globbing

bashwildcards

After coming from cygwin, I'm quite confused about the bash (version 4.1.5) globbing on my Ubuntu 10.4. I'd love one of the following two possibilities:

  • ignore . and .., match everything else
  • ignore filenames starting with a dot unless given explicitly

The current behavior is plain strange:

cd; ls .*

says "ls: cannot access .*: No such file or directory" although I explicitly asked for filenames starting with a dot.

cd; ls .gnupg/*.gpg

complains as well although I'm asking for files not starting with a dot (it's just the directory name what starts with a dot).

Output of shopt -p

(removed)

The solution

I've changed shopt to values from another user (not having this problem) and it didn't help. Then I came to the idea to bisect my .bashrc and find the offending line which contained something like GLOBIGNORE='.[!/.]*:..[!/]*:*/.[!/.]*:*/..[!/]*:

I've replaced it by GLOBIGNORE='.:..', which does nearly what I want, and it works.

Best Answer

Unfortunately, I must answer my own question. It was GLOBIGNORE. From the man page:

A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in GLOBIGNORE, it is removed from the list of matches.