Question: I see that extglob is on but I'd like to know where this is set.

```
$ shopt extglob
extglob         on
$

```

Didn't find it in these files.

* `~/.bashrc`
* `~/.bash_profile`
* `~/.profile`
* `/etc/bashrc` (no such file)
* `/etc/bash.bashrc`

Answer: 
On my 14.04 VM, I found it in `/usr/share/bash-completion/bash_completion`:

```
ubuntu@ubuntu:~$ grep extglob /usr/share/bash-completion/bash_completion 
shopt -s extglob progcomp
ubuntu@ubuntu:~$ 

```

This is sourced by `~/.bashrc`:

```
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

```

This can be figured out by running `bash -x`, which shows all sourced startup files and their commands. Run `script -c "bash -x"`, then `exit` in the new interactive shell, then examine the `typescript` file output from script:

```
+ . /usr/share/bash-completion/bash_completion

...

++ shopt -s extglob progcomp

```

The `+`'s indicate the level of sourced file, so when we look one level up from the `shopt` command, we see `/usr/share/bash-completion/bash_completion` is sourced.
It is set under `/usr/share/bash-completion/bash_completion` file:

```
shopt -s extglob progcomp

```

The `~/.bashrc` file has the following, if `posix` option is unset then:

```
if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion

```

That means if the file `/usr/share/bash-completion/bash_completion` exists it will source the file. 

As that file contains the line to set `extglob`, it will be set upon stating of an interactive non-login shell.