1 ## oils_failures_allowed: 4
2 ## compare_shells: bash zsh
3
4 #### globstar is off -> ** is treated like *
5 case $SH in zsh) exit ;; esac
6
7 shopt -u globstar
8
9 mkdir -p c/subdir
10 touch {leaf.md,c/leaf.md,c/subdir/leaf.md}
11
12 echo **/*.* | sort
13 ## STDOUT:
14 c/leaf.md
15 ## END
16 ## N-I zsh STDOUT:
17 ## END
18
19 #### each occurrence of ** recurses through all depths
20 shopt -s globstar
21
22 mkdir -p c/subdir
23 touch {leaf.md,c/leaf.md,c/subdir/leaf.md}
24
25 echo **/*.* | tr ' ' '\n' | sort
26 echo
27 echo **/**/*.* | tr ' ' '\n' | sort
28 ## STDOUT:
29 c/leaf.md
30 c/subdir/leaf.md
31 leaf.md
32
33 c/leaf.md
34 c/subdir/leaf.md
35 leaf.md
36 ## END
37
38 ## BUG zsh STDOUT:
39 c/leaf.md
40 c/subdir/leaf.md
41 leaf.md
42
43 c/leaf.md
44 c/leaf.md
45 c/subdir/leaf.md
46 c/subdir/leaf.md
47 c/subdir/leaf.md
48 leaf.md
49 ## END
50
51 #### within braces, globstar works when there is a comma
52 shopt -s globstar
53
54 mkdir -p c/subdir
55 touch c/subdir/leaf.md
56
57 echo {**/*.*,} | sort | sed 's/[[:space:]]*$//'
58 ## STDOUT:
59 c/subdir/leaf.md
60 ## END
61
62 #### ** behaves like * if adjacent to anything other than /
63 shopt -s globstar
64
65 mkdir directory
66 touch leaf.md
67 touch directory/leaf.md
68
69 echo **/*.* | sort
70 echo directory/**/*.md | sort
71 echo d**/*.md | sort
72 echo **y/*.md | sort
73 echo d**y/*.md | sort
74 ## STDOUT:
75 directory/leaf.md leaf.md
76 directory/leaf.md
77 directory/leaf.md
78 directory/leaf.md
79 directory/leaf.md
80 ## END
81
82 #### in zsh, ***/ follows symlinked directories, while **/ does not
83 case $SH in bash) exit ;; esac
84
85 mkdir directory-1
86 mkdir directory-2
87 touch directory-2/leaf-2.md
88 ln -s -T ../directory-2 directory-1/symlink
89
90 echo **/*.* | sort
91 echo ***/*.* | sort
92 ## STDOUT:
93 directory-2/leaf-2.md
94 directory-1/symlink/leaf-2.md directory-2/leaf-2.md
95 ## END
96 ## N-I bash STDOUT:
97 ## END