OILS / demo / globstar.sh View on Github | oilshell.org

40 lines, 19 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./globstar.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10shopt -s globstar || true
11
12demo() {
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
36with-zsh() {
37 zsh $0 demo
38}
39
40"$@"