1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # ./globstar.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | shopt -s globstar || true
|
11 |
|
12 | demo() {
|
13 | local root=_tmp/globstar
|
14 | mkdir -p $root/{Python,Py}
|
15 |
|
16 | mkdir -p $root/Py/zz/on
|
17 |
|
18 | touch $root/Python/foo.py
|
19 | touch $root/Py/zz/on/bar.py
|
20 |
|
21 | tree $root
|
22 |
|
23 |
|
24 | echo $root/**/*.py
|
25 |
|
26 | # OK this is weird, ** only crosses directory boundaries when it's at the
|
27 | # end? It doesn't exactly make sense.
|
28 | #
|
29 | # Try with zsh too.
|
30 | echo $root/Py**on/*.py
|
31 |
|
32 | echo "zsh version: ${ZSH_VERSION:-}"
|
33 | echo "bash version: ${BASH_VERSION:-}"
|
34 | }
|
35 |
|
36 | with-zsh() {
|
37 | zsh $0 demo
|
38 | }
|
39 |
|
40 | "$@"
|