| 1 | ## compare_shells: bash
|
| 2 |
|
| 3 | #### shopt -s nullglob
|
| 4 | argv.py _tmp/spec-tmp/*.nonexistent
|
| 5 | shopt -s nullglob
|
| 6 | argv.py _tmp/spec-tmp/*.nonexistent
|
| 7 | ## STDOUT:
|
| 8 | ['_tmp/spec-tmp/*.nonexistent']
|
| 9 | []
|
| 10 | ## END
|
| 11 | ## N-I dash/mksh/ash STDOUT:
|
| 12 | ['_tmp/spec-tmp/*.nonexistent']
|
| 13 | ['_tmp/spec-tmp/*.nonexistent']
|
| 14 | ## END
|
| 15 |
|
| 16 | #### shopt -s failglob in command context
|
| 17 | argv.py *.ZZ
|
| 18 | shopt -s failglob
|
| 19 | argv.py *.ZZ # nothing is printed, not []
|
| 20 | echo status=$?
|
| 21 | ## STDOUT:
|
| 22 | ['*.ZZ']
|
| 23 | status=1
|
| 24 | ## END
|
| 25 | ## N-I dash/mksh/ash STDOUT:
|
| 26 | ['*.ZZ']
|
| 27 | ['*.ZZ']
|
| 28 | status=0
|
| 29 | ## END
|
| 30 |
|
| 31 | #### shopt -s failglob in loop context
|
| 32 | for x in *.ZZ; do echo $x; done
|
| 33 | echo status=$?
|
| 34 | shopt -s failglob
|
| 35 | for x in *.ZZ; do echo $x; done
|
| 36 | echo status=$?
|
| 37 | ## STDOUT:
|
| 38 | *.ZZ
|
| 39 | status=0
|
| 40 | status=1
|
| 41 | ## END
|
| 42 | ## N-I dash/mksh/ash STDOUT:
|
| 43 | *.ZZ
|
| 44 | status=0
|
| 45 | *.ZZ
|
| 46 | status=0
|
| 47 | ## END
|
| 48 |
|
| 49 | #### shopt -s failglob in array literal context
|
| 50 | myarr=(*.ZZ)
|
| 51 | echo "${myarr[@]}"
|
| 52 | shopt -s failglob
|
| 53 | myarr=(*.ZZ)
|
| 54 | echo status=$?
|
| 55 | ## STDOUT:
|
| 56 | *.ZZ
|
| 57 | status=1
|
| 58 | ## END
|
| 59 | ## N-I mksh STDOUT:
|
| 60 | *.ZZ
|
| 61 | status=0
|
| 62 | ## END
|
| 63 | ## N-I dash/ash stdout-json: ""
|
| 64 | ## N-I dash/ash status: 2
|
| 65 |
|
| 66 | #### shopt -s failglob exits properly in command context with set -e
|
| 67 | set -e
|
| 68 | argv.py *.ZZ
|
| 69 | shopt -s failglob
|
| 70 | argv.py *.ZZ
|
| 71 | echo status=$?
|
| 72 | ## STDOUT:
|
| 73 | ['*.ZZ']
|
| 74 | ## END
|
| 75 | ## status: 1
|
| 76 | ## N-I dash/mksh/ash STDOUT:
|
| 77 | ['*.ZZ']
|
| 78 | ## END
|
| 79 | ## N-I dash/mksh/ash status: 127
|
| 80 |
|
| 81 | #### shopt -s failglob exits properly in loop context with set -e
|
| 82 | set -e
|
| 83 | for x in *.ZZ; do echo $x; done
|
| 84 | echo status=$?
|
| 85 |
|
| 86 | shopt -s failglob
|
| 87 | for x in *.ZZ; do echo $x; done
|
| 88 | echo status=$?
|
| 89 |
|
| 90 | ## status: 1
|
| 91 | ## STDOUT:
|
| 92 | *.ZZ
|
| 93 | status=0
|
| 94 | ## END
|
| 95 |
|
| 96 | ## N-I dash/mksh/ash status: 127
|
| 97 | ## N-I dash/mksh/ash STDOUT:
|
| 98 | *.ZZ
|
| 99 | status=0
|
| 100 | ## END
|
| 101 |
|
| 102 | #### shopt -s failglob behavior on single line with semicolon
|
| 103 | # bash behaves differently when commands are separated by a semicolon than when
|
| 104 | # separated by a newline. This behavior doesn't make sense or seem to be
|
| 105 | # intentional, so osh does not mimic it.
|
| 106 |
|
| 107 | shopt -s failglob
|
| 108 | echo *.ZZ; echo status=$? # bash doesn't execute the second part!
|
| 109 | echo *.ZZ
|
| 110 | echo status=$? # bash executes this
|
| 111 |
|
| 112 | ## STDOUT:
|
| 113 | status=1
|
| 114 | ## END
|
| 115 |
|
| 116 | ## OK osh STDOUT:
|
| 117 | status=1
|
| 118 | status=1
|
| 119 | ## END
|
| 120 |
|
| 121 | ## N-I dash/mksh/ash STDOUT:
|
| 122 | *.ZZ
|
| 123 | status=0
|
| 124 | *.ZZ
|
| 125 | status=0
|
| 126 | ## END
|
| 127 |
|
| 128 | #### dotglob (bash option that dashglob is roughly consistent with)
|
| 129 | mkdir -p $TMP/dotglob
|
| 130 | cd $TMP/dotglob
|
| 131 | touch .foorc other
|
| 132 |
|
| 133 | echo *
|
| 134 | shopt -s dotglob
|
| 135 | echo * | sort
|
| 136 | ## STDOUT:
|
| 137 | other
|
| 138 | .foorc other
|
| 139 | ## END
|
| 140 | ## N-I dash/mksh/ash STDOUT:
|
| 141 | other
|
| 142 | other
|
| 143 | ## END
|
| 144 |
|