| 1 | ## compare_shells: bash dash mksh zsh ash
|
| 2 | ## oils_failures_allowed: 4
|
| 3 |
|
| 4 | # This file relates to:
|
| 5 | #
|
| 6 | # - doc/known-differences.md
|
| 7 | # - "divergence" tag on github:
|
| 8 | # https://github.com/oils-for-unix/oils/issues?q=is%3Aissue%20state%3Aopen%20label%3Adivergence
|
| 9 |
|
| 10 | #### xz package: dirprefix="${line##*([}"
|
| 11 |
|
| 12 | # https://oilshell.zulipchat.com/#narrow/channel/502349-osh/topic/alpine.20xz.20-.20.22.24.7Bline.23.23*.28.5B.7D.22.20interpreted.20as.20extended.20glob/with/519718284
|
| 13 |
|
| 14 | # NOTE: spec/extglob-match shows that bash respects it
|
| 15 | #
|
| 16 | # echo 'strip ##' ${x##@(foo)}
|
| 17 |
|
| 18 | shopt -s extglob
|
| 19 |
|
| 20 |
|
| 21 | dirprefix="${line##*([}"
|
| 22 | echo "-$dirprefix-"
|
| 23 |
|
| 24 | # Now try with real data
|
| 25 | line='*([foo'
|
| 26 | dirprefix="${line##*([}"
|
| 27 | echo "-$dirprefix-"
|
| 28 |
|
| 29 | ## STDOUT:
|
| 30 | --
|
| 31 | -foo-
|
| 32 | ## END
|
| 33 |
|
| 34 | ## N-I mksh/zsh status: 1
|
| 35 | ## N-I mksh/zsh STDOUT:
|
| 36 | ## END
|
| 37 |
|
| 38 | #### !( as negation and subshell versus extended glob - #2463
|
| 39 |
|
| 40 | have_icu_uc=false
|
| 41 | have_icu_i18n=false
|
| 42 |
|
| 43 | if !($have_icu_uc && $have_icu_i18n); then
|
| 44 | echo one
|
| 45 | fi
|
| 46 | echo two
|
| 47 |
|
| 48 | ## STDOUT:
|
| 49 | one
|
| 50 | two
|
| 51 | ## END
|
| 52 |
|
| 53 | ## BUG mksh STDOUT:
|
| 54 | two
|
| 55 | ## END
|
| 56 |
|
| 57 | #### Changing PATH will invalidate PATH cache
|
| 58 |
|
| 59 | mkdir -p _tmp/bin
|
| 60 | mkdir -p _tmp/bin2
|
| 61 | printf '#!/usr/bin/env sh\necho hi\n' >_tmp/bin/hello
|
| 62 | printf '#!/usr/bin/env sh\necho hey\n' >_tmp/bin2/hello
|
| 63 | chmod +x _tmp/bin/hello
|
| 64 | chmod +x _tmp/bin2/hello
|
| 65 |
|
| 66 | BIN=$PWD/_tmp/bin
|
| 67 | BIN2=$PWD/_tmp/bin2
|
| 68 |
|
| 69 | # Will find _tmp/bin/hello
|
| 70 | PATH="$BIN:$PATH" hello
|
| 71 | echo status=$?
|
| 72 |
|
| 73 | # Should invalidate cache and then find _tmp/bin2/hello
|
| 74 | PATH="$BIN2:$PATH" hello
|
| 75 | echo status=$?
|
| 76 |
|
| 77 | # Same when PATH= and export PATH=
|
| 78 | PATH="$BIN:$PATH"
|
| 79 | hello
|
| 80 | echo status=$?
|
| 81 | PATH="$BIN2:$PATH"
|
| 82 | hello
|
| 83 | echo status=$?
|
| 84 |
|
| 85 | export PATH="$BIN:$PATH"
|
| 86 | hello
|
| 87 | echo status=$?
|
| 88 | export PATH="$BIN2:$PATH"
|
| 89 | hello
|
| 90 | echo status=$?
|
| 91 |
|
| 92 | ## STDOUT:
|
| 93 | hi
|
| 94 | status=0
|
| 95 | hey
|
| 96 | status=0
|
| 97 | hi
|
| 98 | status=0
|
| 99 | hey
|
| 100 | status=0
|
| 101 | hi
|
| 102 | status=0
|
| 103 | hey
|
| 104 | status=0
|
| 105 | ## END
|
| 106 |
|
| 107 | #### test builtin - Unexpected trailing word '--' (#2409)
|
| 108 |
|
| 109 | # Minimal repro of sqsh build error
|
| 110 | set -- -o; test $# -ne 0 -a "$1" != "--"
|
| 111 | echo status=$?
|
| 112 |
|
| 113 | # Now hardcode $1
|
| 114 | test $# -ne 0 -a "-o" != "--"
|
| 115 | echo status=$?
|
| 116 |
|
| 117 | # Remove quotes around -o
|
| 118 | test $# -ne 0 -a -o != "--"
|
| 119 | echo status=$?
|
| 120 |
|
| 121 | # How about a different flag?
|
| 122 | set -- -z; test $# -ne 0 -a "$1" != "--"
|
| 123 | echo status=$?
|
| 124 |
|
| 125 | # A non-flag?
|
| 126 | set -- z; test $# -ne 0 -a "$1" != "--"
|
| 127 | echo status=$?
|
| 128 |
|
| 129 | ## STDOUT:
|
| 130 | status=0
|
| 131 | status=0
|
| 132 | status=0
|
| 133 | status=0
|
| 134 | status=0
|
| 135 | ## END
|
| 136 |
|
| 137 | #### set -u failure in eval doesn't exit the parent process
|
| 138 | set -u
|
| 139 | test_function() {
|
| 140 | x=$1
|
| 141 | }
|
| 142 |
|
| 143 | echo "before"
|
| 144 | eval test_function
|
| 145 | # bash spec says that set -u failures should exit the shell
|
| 146 | # posix spec says that eval shall read and execute a command by the current shell, so the
|
| 147 | # running shell should exit too
|
| 148 | echo "after"
|
| 149 | ## status: 1
|
| 150 | ## OK ash/dash status: 2
|
| 151 | ## BUG mksh/zsh status: 0
|
| 152 | ## STDOUT:
|
| 153 | before
|
| 154 | ## END
|
| 155 | ## BUG zsh/mksh STDOUT:
|
| 156 | before
|
| 157 | after
|
| 158 | ## END
|
| 159 |
|
| 160 | #### set -u nested evals
|
| 161 | set -u
|
| 162 | test_function_2() {
|
| 163 | x=$blarg
|
| 164 | }
|
| 165 | test_function() {
|
| 166 | eval "test_function_2"
|
| 167 | }
|
| 168 |
|
| 169 | echo "before"
|
| 170 | eval test_function
|
| 171 | echo "after"
|
| 172 | ## status: 1
|
| 173 | ## OK ash/dash status: 2
|
| 174 | ## BUG mksh/zsh status: 0
|
| 175 | ## STDOUT:
|
| 176 | before
|
| 177 | ## END
|
| 178 | ## BUG zsh/mksh STDOUT:
|
| 179 | before
|
| 180 | after
|
| 181 | ## END
|
| 182 |
|
| 183 | #### builtin cat crashes a subshell (#2530)
|
| 184 |
|
| 185 | ((/usr/bin/cat </dev/zero; echo $? >&7) | true) 7>&1
|
| 186 |
|
| 187 | ((cat </dev/zero; echo $? >&7) | true) 7>&1
|
| 188 |
|
| 189 | ## STDOUT:
|
| 190 | 141
|
| 191 | 141
|
| 192 | ## END
|