Bash – change the shell’s wildcards

bashshellwildcards

The three wildcards in the unix shell are *, ?, and []. Can I change the settings of such wildcards? For example, the symbol or their behaviour?

In an attempt to answer the question myself, I searched for "create new wildcard shell" and "change wildcard shell settings" but could not find anything relevant. Are these settings "hard-coded" into the shell?

PS: I guess I'm referring to bash, which is the default one I use (Xubuntu). Maybe other shells like tcsh, ksh, fish, etc are more customizable?

Best Answer

No, you can't. Not without recompiling Bash. But changing something as basic and ubiquitous as the glob characters would break compatibility with a huge majority of Bash scripts, so if you do this, please don't call the resulting binary "bash."

zsh has more flexibility in its globbing, but even then you can't arbitrarily define your own syntax.

The closest thing to what you want (redefinable pattern matching languages) isn't in any shell, but sounds a lot like Perl 6. Be warned: it's not for the faint of heart.