Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I'm a lazy bum and want to avoid putting every string in quotes when passing arguments to a function, how do I avoid the characters * and ? being used by bash for patname expansion?

Simplified example:

fn () {
    echo "$1"
# shopt -s option - disable * and ?
fn not/*/expanded
fn neither\ should\ this/be/expanded?
fn 'accepted too*'
# shopt -u option - enable * and ?

This should output:

neither should this/be/expanded?
accepted too*
share|improve this question
up vote 6 down vote accepted

The option you arer looking for is noglob and should be set using the shell built-in set.

To enable it:

set -o noglob

To disable it:

set +o noglob

Or also with set -f and set +f.

Yet another method:

shopt -os noglob


shopt -ou noglob
share|improve this answer
It's not a shopt (shell option) but just an "option". Thanks for putting me on the right track. – Lekensteyn May 7 '11 at 16:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.