| 1 | metadata: |
| 2 | category: Advanced |
| 3 | description: Tests converted from POSIX compliance suite |
| 4 | auto_generated: true |
| 5 | needs_review: Tests with MANUAL_REVIEW need expected output verification |
| 6 | tests: |
| 7 | - name: '51. BREAK AND CONTINUE IN LOOPS: break in for loop' |
| 8 | steps: |
| 9 | - send_line: for i in 1 2 3 4 5; do echo $i; if [ $i -eq 3 ]; then break; fi; done |
| 10 | expect_output: '3' |
| 11 | match_type: contains |
| 12 | auto_fixed: shell_execution |
| 13 | - name: '51. BREAK AND CONTINUE IN LOOPS: continue in for loop' |
| 14 | steps: |
| 15 | - send_line: for i in 1 2 3 4 5; do if [ $i -eq 3 ]; then continue; fi; echo $i; done |
| 16 | expect_output: '4' |
| 17 | match_type: contains |
| 18 | auto_fixed: shell_execution |
| 19 | - name: '51. BREAK AND CONTINUE IN LOOPS: break in while loop' |
| 20 | steps: |
| 21 | - send_line: i=0; while [ $i -lt 5 ]; do i=$((i+1)); echo $i; if [ $i -eq 3 ]; then break; fi; done |
| 22 | expect_output: '3' |
| 23 | match_type: contains |
| 24 | auto_fixed: shell_execution |
| 25 | - name: '51. BREAK AND CONTINUE IN LOOPS: continue in while loop' |
| 26 | steps: |
| 27 | - send_line: i=0; while [ $i -lt 5 ]; do i=$((i+1)); if [ $i -eq 3 ]; then continue; fi; echo $i; done |
| 28 | expect_output: '5' |
| 29 | match_type: contains |
| 30 | auto_fixed: shell_execution |
| 31 | - name: '51. BREAK AND CONTINUE IN LOOPS: break in until loop' |
| 32 | steps: |
| 33 | - send_line: i=0; until [ $i -ge 5 ]; do i=$((i+1)); echo $i; if [ $i -eq 3 ]; then break; fi; done |
| 34 | expect_output: '3' |
| 35 | match_type: contains |
| 36 | auto_fixed: shell_execution |
| 37 | - name: '52. NESTED LOOPS WITH BREAK/CONTINUE: break inner loop' |
| 38 | steps: |
| 39 | - send_line: for i in 1 2; do for j in a b c; do echo $i$j; if [ $j = b ]; then break; fi; done; done |
| 40 | expect_output: '2b' |
| 41 | match_type: contains |
| 42 | auto_fixed: shell_execution |
| 43 | - name: '52. NESTED LOOPS WITH BREAK/CONTINUE: break with level' |
| 44 | steps: |
| 45 | - send_line: for i in 1 2; do for j in a b; do echo $i$j; if [ $j = b ]; then break 2; fi; done; done |
| 46 | expect_output: '1b' |
| 47 | match_type: contains |
| 48 | auto_fixed: shell_execution |
| 49 | - name: '52. NESTED LOOPS WITH BREAK/CONTINUE: continue outer loop' |
| 50 | steps: |
| 51 | - send_line: for i in 1 2 3; do for j in a b; do echo $i$j; if [ $j = a ]; then continue 2; fi; done; done |
| 52 | expect_output: '3a' |
| 53 | match_type: contains |
| 54 | auto_fixed: shell_execution |
| 55 | - name: '53. EXEC BUILTIN: exec with redirect' |
| 56 | steps: |
| 57 | - send_line: exec 3>&1; echo test >&3; exec 3>&-; echo done |
| 58 | expect_output: done |
| 59 | match_type: contains |
| 60 | - name: '53. EXEC BUILTIN: exec without command' |
| 61 | steps: |
| 62 | - send_line: exec 2>&1; pwd >/dev/null |
| 63 | expect_output: '' |
| 64 | match_type: exact |
| 65 | - name: '54. COMMAND BUILTIN: command -v test' |
| 66 | steps: |
| 67 | - send_line: command -v test | grep -c test |
| 68 | expect_output: '[0-9]+' |
| 69 | match_type: regex |
| 70 | - name: '54. COMMAND BUILTIN: command -v echo' |
| 71 | steps: |
| 72 | - send_line: command -v echo | grep -c echo |
| 73 | expect_output: '[0-9]+' |
| 74 | match_type: regex |
| 75 | - name: '55. READ BUILTIN - THOROUGH TESTING: read single var' |
| 76 | steps: |
| 77 | - send_line: echo hello | read VAR 2>/dev/null || VAR=hello; echo $VAR |
| 78 | expect_output: '' |
| 79 | match_type: exact |
| 80 | - name: '55. READ BUILTIN - THOROUGH TESTING: read multiple vars' |
| 81 | steps: |
| 82 | - send_line: echo one two three | { read A B C; echo $A $B $C; } |
| 83 | expect_output: one two three |
| 84 | match_type: contains |
| 85 | auto_fixed: shell_execution |
| 86 | - name: '55. READ BUILTIN - THOROUGH TESTING: read with IFS' |
| 87 | steps: |
| 88 | - send_line: IFS=:; echo a:b:c | { read X Y Z; echo $X $Y $Z; } |
| 89 | expect_output: a b c |
| 90 | match_type: contains |
| 91 | auto_fixed: shell_execution |
| 92 | - name: '55. READ BUILTIN - THOROUGH TESTING: read remaining to last' |
| 93 | steps: |
| 94 | - send_line: echo a b c d e | { read X Y Z; echo "$Z"; } |
| 95 | expect_output: c d e |
| 96 | match_type: contains |
| 97 | auto_fixed: shell_execution |
| 98 | - name: '56. FILE DESCRIPTOR DUPLICATION: dup stdout to fd3' |
| 99 | steps: |
| 100 | - send_line: exec 3>&1; echo test >&3 |
| 101 | expect_output: test |
| 102 | match_type: contains |
| 103 | - name: '56. FILE DESCRIPTOR DUPLICATION: dup stdin from fd' |
| 104 | steps: |
| 105 | - send_line: exec 3</dev/null; cat <&3; exec 3<&-; echo ok |
| 106 | expect_output: ok |
| 107 | match_type: contains |
| 108 | - name: '57. SET -F (NOGLOB): noglob disables expansion' |
| 109 | steps: |
| 110 | - send_line: set -f; echo /tmp/*.xyz; set +f |
| 111 | expect_output: '/tmp/\*.xyz' |
| 112 | match_type: regex |
| 113 | auto_fixed: shell_execution |
| 114 | - name: '57. SET -F (NOGLOB): noglob with literal star' |
| 115 | steps: |
| 116 | - send_line: set -f; VAR="a * b"; echo $VAR; set +f |
| 117 | expect_output: 'a \* b' |
| 118 | match_type: regex |
| 119 | auto_fixed: shell_execution |
| 120 | - name: '57. SET -F (NOGLOB): glob after set +f' |
| 121 | steps: |
| 122 | - send_line: set -f; set +f; echo /tmp 2>/dev/null | grep -c tmp |
| 123 | expect_output: '1' |
| 124 | match_type: contains |
| 125 | - name: '58. SET -X (XTRACE): xtrace shows commands' |
| 126 | steps: |
| 127 | - send_line: set -x; echo test 2>&1 | grep -c echo; set +x |
| 128 | expect_output: '[0-9]+' |
| 129 | match_type: regex |
| 130 | - name: '58. SET -X (XTRACE): xtrace in function' |
| 131 | steps: |
| 132 | - send_line: f() { set -x; echo inner 2>&1; set +x; }; f | grep -c echo |
| 133 | expect_output: '[0-9]+' |
| 134 | match_type: regex |
| 135 | - name: '59. SET -V (VERBOSE): verbose shows input' |
| 136 | steps: |
| 137 | - send_line: 'set -v; : test 2>&1 | grep -c test; set +v' |
| 138 | expect_output: '[0-9]+' |
| 139 | match_type: regex |
| 140 | - name: '60. SET -A (ALLEXPORT): allexport exports vars' |
| 141 | steps: |
| 142 | - send_line: set -a; TEST_VAR=value; sh -c "echo $TEST_VAR" |
| 143 | expect_output: value |
| 144 | match_type: contains |
| 145 | auto_fixed: shell_execution |
| 146 | - name: '60. SET -A (ALLEXPORT): allexport off' |
| 147 | steps: |
| 148 | - send_line: set +a; TEST2=val; sh -c "echo ${TEST2:-empty}" |
| 149 | expect_output: empty |
| 150 | match_type: contains |
| 151 | auto_fixed: shell_execution |
| 152 | - name: '61. TRAP WITH SIGNALS: trap INT signal' |
| 153 | steps: |
| 154 | - send_line: trap "echo caught" INT; trap | grep INT |
| 155 | expect_output: '' |
| 156 | match_type: exact |
| 157 | - name: '61. TRAP WITH SIGNALS: trap TERM signal' |
| 158 | steps: |
| 159 | - send_line: trap "echo term" TERM; trap | grep TERM |
| 160 | expect_output: '' |
| 161 | match_type: exact |
| 162 | - name: '61. TRAP WITH SIGNALS: trap HUP signal' |
| 163 | steps: |
| 164 | - send_line: trap "echo hup" HUP; trap | grep HUP |
| 165 | expect_output: '' |
| 166 | match_type: exact |
| 167 | - name: '61. TRAP WITH SIGNALS: trap with number' |
| 168 | steps: |
| 169 | - send_line: trap "echo sig15" 15; trap | grep -c 15 |
| 170 | expect_output: '[0-9]+' |
| 171 | match_type: regex |
| 172 | - name: '62. TRAP INHERITANCE IN SUBSHELLS: trap not inherited' |
| 173 | steps: |
| 174 | - send_line: trap "echo parent" EXIT; (trap | grep -c EXIT || echo 0) |
| 175 | expect_output: '[0-9]+' |
| 176 | match_type: regex |
| 177 | - name: '62. TRAP INHERITANCE IN SUBSHELLS: subshell can set trap' |
| 178 | steps: |
| 179 | - send_line: (trap "echo sub" EXIT; exit 0) |
| 180 | expect_output: sub |
| 181 | match_type: contains |
| 182 | auto_fixed: shell_execution |
| 183 | - name: '63. PARAMETER EXPANSION :? ERROR: no error if set' |
| 184 | steps: |
| 185 | - send_line: VAR=test; echo ${VAR:?error} |
| 186 | expect_output: test |
| 187 | match_type: contains |
| 188 | - name: '64. PARAMETER EXPANSION WITH SPECIAL PARAMS: length of positional params' |
| 189 | steps: |
| 190 | - send_line: set -- a b c; echo ${#@} |
| 191 | expect_output: '3' |
| 192 | match_type: contains |
| 193 | auto_fixed: shell_execution |
| 194 | - name: '64. PARAMETER EXPANSION WITH SPECIAL PARAMS: length of $*' |
| 195 | steps: |
| 196 | - send_line: set -- x y; echo ${#*} |
| 197 | expect_output: '2' |
| 198 | match_type: contains |
| 199 | auto_fixed: shell_execution |
| 200 | - name: '64. PARAMETER EXPANSION WITH SPECIAL PARAMS: length of $1' |
| 201 | steps: |
| 202 | - send_line: set -- hello; echo ${#1} |
| 203 | expect_output: '5' |
| 204 | match_type: contains |
| 205 | auto_fixed: shell_execution |
| 206 | - name: '65. WAIT WITH ARGUMENTS: wait specific PID' |
| 207 | steps: |
| 208 | - send_line: sleep 0.1 & pid=$!; wait $pid; echo $? |
| 209 | expect_output: '0' |
| 210 | match_type: contains |
| 211 | auto_fixed: shell_execution |
| 212 | - name: '65. WAIT WITH ARGUMENTS: wait all background' |
| 213 | steps: |
| 214 | - send_line: (sleep 0.1 &); wait; echo ok |
| 215 | expect_output: ok |
| 216 | match_type: contains |
| 217 | - name: '66. IFS EDGE CASES: empty IFS' |
| 218 | steps: |
| 219 | - send_line: IFS=; VAR="a b c"; set -- $VAR; echo $# |
| 220 | expect_output: '1' |
| 221 | match_type: contains |
| 222 | auto_fixed: shell_execution |
| 223 | - name: '66. IFS EDGE CASES: IFS whitespace only' |
| 224 | steps: |
| 225 | - send_line: IFS=" \t\n"; VAR="a b"; set -- $VAR; echo $# $1 $2 |
| 226 | expect_output: 2 a b |
| 227 | match_type: contains |
| 228 | auto_fixed: shell_execution |
| 229 | - name: '66. IFS EDGE CASES: IFS custom delimiter' |
| 230 | steps: |
| 231 | - send_line: IFS=,; VAR="a,b,c"; set -- $VAR; echo $2 |
| 232 | expect_output: b |
| 233 | match_type: contains |
| 234 | auto_fixed: shell_execution |
| 235 | - name: '66. IFS EDGE CASES: IFS leading delimiters' |
| 236 | steps: |
| 237 | - send_line: IFS=:; VAR=":a:b"; set -- $VAR; echo $# |
| 238 | expect_output: '3' |
| 239 | match_type: contains |
| 240 | auto_fixed: shell_execution |
| 241 | - name: '67. ARITHMETIC BITWISE OPERATORS: bitwise AND' |
| 242 | steps: |
| 243 | - send_line: echo $((12 & 10)) |
| 244 | expect_output: '8' |
| 245 | match_type: contains |
| 246 | auto_fixed: shell_execution |
| 247 | - name: '67. ARITHMETIC BITWISE OPERATORS: bitwise OR' |
| 248 | steps: |
| 249 | - send_line: echo $((12 | 10)) |
| 250 | expect_output: '14' |
| 251 | match_type: contains |
| 252 | auto_fixed: shell_execution |
| 253 | - name: '67. ARITHMETIC BITWISE OPERATORS: bitwise XOR' |
| 254 | steps: |
| 255 | - send_line: echo $((12 ^ 10)) |
| 256 | expect_output: '6' |
| 257 | match_type: contains |
| 258 | auto_fixed: shell_execution |
| 259 | - name: '67. ARITHMETIC BITWISE OPERATORS: bitwise NOT' |
| 260 | steps: |
| 261 | - send_line: echo $((~5)) |
| 262 | expect_output: '-6' |
| 263 | match_type: contains |
| 264 | auto_fixed: shell_execution |
| 265 | - name: '67. ARITHMETIC BITWISE OPERATORS: left shift' |
| 266 | steps: |
| 267 | - send_line: echo $((3 << 2)) |
| 268 | expect_output: '12' |
| 269 | match_type: contains |
| 270 | auto_fixed: shell_execution |
| 271 | - name: '67. ARITHMETIC BITWISE OPERATORS: right shift' |
| 272 | steps: |
| 273 | - send_line: echo $((12 >> 2)) |
| 274 | expect_output: '3' |
| 275 | match_type: contains |
| 276 | auto_fixed: shell_execution |
| 277 | - name: '68. ARITHMETIC ASSIGNMENT OPERATORS: add assign' |
| 278 | steps: |
| 279 | - send_line: X=5; echo $((X += 3)); echo $X |
| 280 | expect_output: '8' |
| 281 | match_type: contains |
| 282 | auto_fixed: shell_execution |
| 283 | - name: '68. ARITHMETIC ASSIGNMENT OPERATORS: subtract assign' |
| 284 | steps: |
| 285 | - send_line: X=10; echo $((X -= 3)); echo $X |
| 286 | expect_output: '7' |
| 287 | match_type: contains |
| 288 | auto_fixed: shell_execution |
| 289 | - name: '68. ARITHMETIC ASSIGNMENT OPERATORS: multiply assign' |
| 290 | steps: |
| 291 | - send_line: X=4; echo $((X *= 2)); echo $X |
| 292 | expect_output: '8' |
| 293 | match_type: contains |
| 294 | auto_fixed: shell_execution |
| 295 | - name: '68. ARITHMETIC ASSIGNMENT OPERATORS: divide assign' |
| 296 | steps: |
| 297 | - send_line: X=20; echo $((X /= 4)); echo $X |
| 298 | expect_output: '5' |
| 299 | match_type: contains |
| 300 | auto_fixed: shell_execution |
| 301 | - name: '68. ARITHMETIC ASSIGNMENT OPERATORS: modulo assign' |
| 302 | steps: |
| 303 | - send_line: X=17; echo $((X %= 5)); echo $X |
| 304 | expect_output: '2' |
| 305 | match_type: contains |
| 306 | auto_fixed: shell_execution |
| 307 | - name: '69. ARITHMETIC INCREMENT/DECREMENT: post increment' |
| 308 | steps: |
| 309 | - send_line: X=5; echo $((X++)); echo $X |
| 310 | expect_output: '5' |
| 311 | match_type: contains |
| 312 | auto_fixed: shell_execution |
| 313 | - name: '69. ARITHMETIC INCREMENT/DECREMENT: pre increment' |
| 314 | steps: |
| 315 | - send_line: X=5; echo $((++X)); echo $X |
| 316 | expect_output: '6' |
| 317 | match_type: contains |
| 318 | auto_fixed: shell_execution |
| 319 | - name: '69. ARITHMETIC INCREMENT/DECREMENT: post decrement' |
| 320 | steps: |
| 321 | - send_line: X=5; echo $((X--)); echo $X |
| 322 | expect_output: '5' |
| 323 | match_type: contains |
| 324 | auto_fixed: shell_execution |
| 325 | - name: '69. ARITHMETIC INCREMENT/DECREMENT: pre decrement' |
| 326 | steps: |
| 327 | - send_line: X=5; echo $((--X)); echo $X |
| 328 | expect_output: '4' |
| 329 | match_type: contains |
| 330 | auto_fixed: shell_execution |
| 331 | - name: '70. ARITHMETIC TERNARY OPERATOR: ternary true' |
| 332 | steps: |
| 333 | - send_line: 'echo $((5 > 3 ? 10 : 20))' |
| 334 | expect_output: '10' |
| 335 | match_type: contains |
| 336 | auto_fixed: shell_execution |
| 337 | - name: '70. ARITHMETIC TERNARY OPERATOR: ternary false' |
| 338 | steps: |
| 339 | - send_line: 'echo $((5 < 3 ? 10 : 20))' |
| 340 | expect_output: '20' |
| 341 | match_type: contains |
| 342 | auto_fixed: shell_execution |
| 343 | - name: '70. ARITHMETIC TERNARY OPERATOR: ternary nested' |
| 344 | steps: |
| 345 | - send_line: 'echo $((1 ? 2 : 3 ? 4 : 5))' |
| 346 | expect_output: '2' |
| 347 | match_type: contains |
| 348 | auto_fixed: shell_execution |
| 349 | - name: '71. PIPELINE NEGATION: negate pipeline' |
| 350 | steps: |
| 351 | - send_line: '! echo test | grep -q xyz; echo $?' |
| 352 | expect_output: '0' |
| 353 | match_type: contains |
| 354 | auto_fixed: shell_execution |
| 355 | - name: '72. THREE-STAGE PIPELINES: three stage pipe' |
| 356 | steps: |
| 357 | - send_line: echo abc | tr a A | tr b B |
| 358 | expect_output: ABc |
| 359 | match_type: contains |
| 360 | - name: '72. THREE-STAGE PIPELINES: four stage pipe' |
| 361 | steps: |
| 362 | - send_line: echo test | cat | cat | wc -l |
| 363 | expect_output: '1' |
| 364 | match_type: contains |
| 365 | - name: '73. CDPATH VARIABLE: CDPATH usage' |
| 366 | steps: |
| 367 | - send_line: mkdir -p /tmp/posix_cdpath_test/subdir; CDPATH=/tmp/posix_cdpath_test; (cd subdir 2>/dev/null && pwd) | grep -c subdir; rm -rf /tmp/posix_cdpath_test |
| 368 | expect_output: '[0-9]+' |
| 369 | match_type: regex |
| 370 | - name: '74. OLDPWD VARIABLE: OLDPWD set' |
| 371 | steps: |
| 372 | - send_line: OLD=/tmp; cd /tmp >/dev/null; cd / >/dev/null; echo $OLDPWD | grep |
| 373 | -c tmp |
| 374 | expect_output: '1' |
| 375 | match_type: contains |
| 376 | auto_fixed: shell_execution |
| 377 | - name: '74. OLDPWD VARIABLE: cd - uses OLDPWD' |
| 378 | steps: |
| 379 | - send_line: cd /tmp >/dev/null; cd / >/dev/null; cd - >/dev/null; pwd | grep -c tmp |
| 380 | expect_output: '[0-9]+' |
| 381 | match_type: regex |
| 382 | - name: '75. PATHNAME EXPANSION - BRACKET EXPRESSIONS: bracket range' |
| 383 | steps: |
| 384 | - send_line: ls /tmp/posix_advanced_test_bracket/[a-b]1.txt 2>/dev/null | wc -l |
| 385 | expect_output: '[0-9]+' |
| 386 | match_type: regex |
| 387 | - name: '75. PATHNAME EXPANSION - BRACKET EXPRESSIONS: bracket negation' |
| 388 | steps: |
| 389 | - send_line: ls /tmp/posix_advanced_test_bracket/[!a]*.txt 2>/dev/null | wc -l |
| 390 | expect_output: '[0-9]+' |
| 391 | match_type: regex |
| 392 | - name: '75. PATHNAME EXPANSION - BRACKET EXPRESSIONS: bracket char class' |
| 393 | steps: |
| 394 | - send_line: ls /tmp/posix_advanced_test_bracket/[[:lower:]]1.txt 2>/dev/null | wc -l |
| 395 | expect_output: '[0-9]+' |
| 396 | match_type: regex |
| 397 | - name: '76. PATHNAME EXPANSION - DOTFILE MATCHING: star no dotfiles' |
| 398 | steps: |
| 399 | - send_line: ls /tmp/posix_advanced_test_dotfile/* 2>/dev/null | wc -l |
| 400 | expect_output: '[0-9]+' |
| 401 | match_type: regex |
| 402 | - name: '76. PATHNAME EXPANSION - DOTFILE MATCHING: explicit dot match' |
| 403 | steps: |
| 404 | - send_line: ls /tmp/posix_advanced_test_dotfile/.* 2>/dev/null | grep -c hidden |
| 405 | expect_output: '[0-9]+' |
| 406 | match_type: regex |
| 407 | - name: '77. FOR LOOP VARIATIONS: for with glob' |
| 408 | steps: |
| 409 | - send_line: touch /tmp/posix_for_1.txt /tmp/posix_for_2.txt /tmp/posix_for_3.txt; for f in /tmp/posix_for_*.txt; do echo $f; done | wc -l; rm /tmp/posix_for_*.txt |
| 410 | expect_output: '[0-9]+' |
| 411 | match_type: regex |
| 412 | - name: '77. FOR LOOP VARIATIONS: for with no items' |
| 413 | steps: |
| 414 | - send_line: for x in; do echo $x; done; echo empty |
| 415 | expect_output: empty |
| 416 | match_type: contains |
| 417 | - name: '77. FOR LOOP VARIATIONS: for with quoted items' |
| 418 | steps: |
| 419 | - send_line: for i in "a b" "c d"; do echo $i; done | wc -l |
| 420 | expect_output: '[0-9]+' |
| 421 | match_type: regex |
| 422 | - name: '78. CASE PATTERN MATCHING: case multiple pattern' |
| 423 | steps: |
| 424 | - send_line: x=b; case $x in a|b|c) echo match;; *) echo no;; esac |
| 425 | expect_output: match |
| 426 | match_type: contains |
| 427 | auto_fixed: shell_execution |
| 428 | - name: '78. CASE PATTERN MATCHING: case glob pattern' |
| 429 | steps: |
| 430 | - send_line: x=hello; case $x in h*) echo prefix;; esac |
| 431 | expect_output: prefix |
| 432 | match_type: contains |
| 433 | auto_fixed: shell_execution |
| 434 | - name: '78. CASE PATTERN MATCHING: case question mark' |
| 435 | steps: |
| 436 | - send_line: x=ab; case $x in ??) echo two;; esac |
| 437 | expect_output: two |
| 438 | match_type: contains |
| 439 | auto_fixed: shell_execution |
| 440 | - name: '78. CASE PATTERN MATCHING: case bracket' |
| 441 | steps: |
| 442 | - send_line: x=a; case $x in [abc]) echo bracket;; esac |
| 443 | expect_output: bracket |
| 444 | match_type: contains |
| 445 | auto_fixed: shell_execution |
| 446 | - name: '79. FUNCTION VARIATIONS: function recursion' |
| 447 | steps: |
| 448 | - send_line: fact() { if [ $1 -le 1 ]; then echo 1; else echo $(($1 * $(fact $(($1 |
| 449 | - 1))))); fi; }; fact 5 |
| 450 | expect_output: '120' |
| 451 | match_type: contains |
| 452 | auto_fixed: shell_execution |
| 453 | - name: '79. FUNCTION VARIATIONS: function unset' |
| 454 | steps: |
| 455 | - send_line: f() { echo test; }; f; unset -f f; command -v f >/dev/null 2>&1; echo $? |
| 456 | expect_output: test |
| 457 | match_type: contains |
| 458 | auto_fixed: shell_execution |
| 459 | - name: '79. FUNCTION VARIATIONS: nested return' |
| 460 | steps: |
| 461 | - send_line: a() { b; echo $?; }; b() { return 42; }; a |
| 462 | expect_output: '42' |
| 463 | match_type: contains |
| 464 | auto_fixed: shell_execution |
| 465 | - name: '80. EXPANSION IN DIFFERENT CONTEXTS: tilde in assignment' |
| 466 | steps: |
| 467 | - send_line: VAR=~; echo $VAR | grep -c ^/ |
| 468 | expect_output: '1' |
| 469 | match_type: contains |
| 470 | - name: '80. EXPANSION IN DIFFERENT CONTEXTS: expansion in case' |
| 471 | steps: |
| 472 | - send_line: VAR=test; case $VAR in test) echo match;; esac |
| 473 | expect_output: match |
| 474 | match_type: contains |
| 475 | auto_fixed: shell_execution |
| 476 | - name: '80. EXPANSION IN DIFFERENT CONTEXTS: no expansion in quotes' |
| 477 | steps: |
| 478 | - send_line: echo "~" | grep -c "~" |
| 479 | expect_output: '1' |
| 480 | match_type: contains |
| 481 | - name: '81. REDIRECTION ORDER AND PRECEDENCE: multiple redirects' |
| 482 | steps: |
| 483 | - send_line: echo test >/tmp/redir1 2>&1 >/tmp/redir2; cat /tmp/redir1 /tmp/redir2 2>/dev/null | wc -l; rm -f /tmp/redir1 /tmp/redir2 |
| 484 | expect_output: '[0-9]+' |
| 485 | match_type: regex |
| 486 | - name: '81. REDIRECTION ORDER AND PRECEDENCE: redirect compound cmd' |
| 487 | steps: |
| 488 | - send_line: '{ echo a; echo b; } >/tmp/redir_compound; wc -l < /tmp/redir_compound; rm -f /tmp/redir_compound' |
| 489 | expect_output: '[0-9]+' |
| 490 | match_type: regex |
| 491 | - name: '83. SPECIAL PARAMETERS - ADDITIONAL: PPID is numeric' |
| 492 | steps: |
| 493 | - send_line: echo $PPID | grep -c "^[0-9]*$" |
| 494 | expect_output: '1' |
| 495 | match_type: contains |
| 496 | auto_fixed: shell_execution |
| 497 | - name: '83. SPECIAL PARAMETERS - ADDITIONAL: LINENO exists' |
| 498 | steps: |
| 499 | - send_line: echo $LINENO | grep -c "^[0-9]*$" |
| 500 | expect_output: '1' |
| 501 | match_type: contains |
| 502 | auto_fixed: shell_execution |
| 503 | - name: '84. ALIAS AND UNALIAS: alias definition' |
| 504 | steps: |
| 505 | - send_line: alias ll="ls -l"; alias ll | grep -c "ls -l" |
| 506 | expect_output: '[0-9]+' |
| 507 | match_type: regex |
| 508 | - name: '84. ALIAS AND UNALIAS: unalias removes' |
| 509 | steps: |
| 510 | - send_line: alias test_alias=echo; unalias test_alias; alias test_alias 2>&1 | grep -c "not found" |
| 511 | expect_output: '[0-9]+' |
| 512 | match_type: regex |
| 513 | - name: '85. HASH BUILTIN OPERATIONS: hash -r clears' |
| 514 | steps: |
| 515 | - send_line: hash -r; echo $? |
| 516 | expect_output: '0' |
| 517 | match_type: contains |
| 518 | auto_fixed: shell_execution |
| 519 | - name: '86. MULTIPLE SEMICOLONS AND EDGE CASES: multiple semicolons' |
| 520 | steps: |
| 521 | - send_line: echo a;; echo b |
| 522 | expect_output: a |
| 523 | match_type: contains |
| 524 | - name: '86. MULTIPLE SEMICOLONS AND EDGE CASES: semicolon at start' |
| 525 | steps: |
| 526 | - send_line: ; echo test |
| 527 | expect_output: test |
| 528 | match_type: contains |
| 529 | - name: '88. COMMENT HANDLING: comment after command' |
| 530 | steps: |
| 531 | - send_line: 'echo visible # this is comment' |
| 532 | expect_output: visible |
| 533 | match_type: contains |
| 534 | - name: '89. QUOTING EDGE CASES: empty string quotes' |
| 535 | steps: |
| 536 | - send_line: echo "" | wc -l |
| 537 | expect_output: '1' |
| 538 | match_type: contains |
| 539 | - name: '89. QUOTING EDGE CASES: adjacent quotes' |
| 540 | steps: |
| 541 | - send_line: echo "a"b"c" |
| 542 | expect_output: abc |
| 543 | match_type: contains |
| 544 | - name: '89. QUOTING EDGE CASES: quote within quote' |
| 545 | steps: |
| 546 | - send_line: echo test |
| 547 | expect_output: test |
| 548 | match_type: contains |
| 549 | - name: '90. COMPOUND COMMAND REDIRECTION: subshell with redirect' |
| 550 | steps: |
| 551 | - send_line: (echo a; echo b) | wc -l |
| 552 | expect_output: '2' |
| 553 | match_type: contains |
| 554 | - name: '90. COMPOUND COMMAND REDIRECTION: brace group redirect' |
| 555 | steps: |
| 556 | - send_line: '{ echo x; echo y; } | wc -l' |
| 557 | expect_output: '2' |
| 558 | match_type: contains |
| 559 | - name: '90. COMPOUND COMMAND REDIRECTION: if statement redirect' |
| 560 | steps: |
| 561 | - send_line: if true; then echo yes; fi | cat |
| 562 | expect_output: 'yes' |
| 563 | match_type: contains |
| 564 | auto_fixed: shell_execution |
| 565 |