metadata: category: Test description: Tests converted from POSIX compliance suite auto_generated: true needs_review: Tests with MANUAL_REVIEW need expected output verification tests: - name: '1. POSIX BASIC COMMANDS: echo simple' steps: - send_line: echo hello expect_output: hello match_type: contains - name: '1. POSIX BASIC COMMANDS: echo with args' steps: - send_line: echo one two three expect_output: one two three match_type: contains - name: '1. POSIX BASIC COMMANDS: printf basic' steps: - send_line: printf 'test\n' expect_output: test match_type: contains auto_fixed: shell_execution - name: '1. POSIX BASIC COMMANDS: printf with args' steps: - send_line: printf '%s %d\n' hello 42 expect_output: hello 42 match_type: contains auto_fixed: shell_execution - name: '2. POSIX VARIABLE EXPANSION: simple variable' steps: - send_line: VAR=test; echo $VAR expect_output: test match_type: contains - name: '2. POSIX VARIABLE EXPANSION: variable in quotes' steps: - send_line: VAR=test; echo "$VAR" expect_output: test match_type: contains - name: '2. POSIX VARIABLE EXPANSION: multiple vars' steps: - send_line: A=hello; B=world; echo $A $B expect_output: hello world match_type: contains - name: '2. POSIX VARIABLE EXPANSION: undefined variable' steps: - send_line: echo $UNDEFINED_VAR_XYZ_987 expect_output: '' match_type: exact - name: '3. POSIX PARAMETER EXPANSION: default value' steps: - send_line: echo "${UNSET:-default}" expect_output: default match_type: contains - name: '3. POSIX PARAMETER EXPANSION: assign default' steps: - send_line: UNSET=; echo "${UNSET:=assigned}"; echo $UNSET expect_output: assigned match_type: contains - name: '3. POSIX PARAMETER EXPANSION: error if unset' steps: - send_line: echo "${VAR:+alternative}" expect_output: '' match_type: exact - name: '3. POSIX PARAMETER EXPANSION: string length' steps: - send_line: VAR=hello; echo "${#VAR}" expect_output: '5' match_type: contains - name: '3. POSIX PARAMETER EXPANSION: remove shortest prefix' steps: - send_line: VAR=foo.bar.baz; echo "${VAR#*.}" expect_output: bar.baz match_type: contains - name: '3. POSIX PARAMETER EXPANSION: remove longest prefix' steps: - send_line: VAR=foo.bar.baz; echo "${VAR##*.}" expect_output: baz match_type: contains auto_fixed: shell_execution - name: '3. POSIX PARAMETER EXPANSION: prefix no match' steps: - send_line: VAR=hello; echo "${VAR#x*}" expect_output: hello match_type: contains auto_fixed: shell_execution - name: '3. POSIX PARAMETER EXPANSION: prefix remove slash' steps: - send_line: VAR=/usr/local/bin; echo "${VAR#/*/}" expect_output: local/bin match_type: contains auto_fixed: shell_execution - name: '3. POSIX PARAMETER EXPANSION: remove shortest suffix' steps: - send_line: VAR=foo.bar.baz; echo "${VAR%.*}" expect_output: foo.bar match_type: contains auto_fixed: shell_execution - name: '3. POSIX PARAMETER EXPANSION: remove longest suffix' steps: - send_line: VAR=foo.bar.baz; echo "${VAR%%.*}" expect_output: foo match_type: contains auto_fixed: shell_execution - name: '3. POSIX PARAMETER EXPANSION: suffix no match' steps: - send_line: VAR=hello; echo "${VAR%x*}" expect_output: hello match_type: contains auto_fixed: shell_execution - name: '3. POSIX PARAMETER EXPANSION: suffix remove extension' steps: - send_line: VAR=file.tar.gz; echo "${VAR%.gz}" expect_output: file.tar match_type: contains auto_fixed: shell_execution - name: '4. POSIX COMMAND SUBSTITUTION: backtick substitution' steps: - send_line: echo `echo test` expect_output: test match_type: contains - name: '4. POSIX COMMAND SUBSTITUTION: dollar paren substitution' steps: - send_line: echo $(echo test) expect_output: test match_type: contains - name: '4. POSIX COMMAND SUBSTITUTION: nested substitution' steps: - send_line: echo $(echo $(echo nested)) expect_output: nested match_type: contains auto_fixed: shell_execution - name: '5. POSIX ARITHMETIC: expr addition' steps: - send_line: expr 5 + 3 expect_output: '8' match_type: contains auto_fixed: shell_execution - name: '5. POSIX ARITHMETIC: expr multiplication' steps: - send_line: expr 4 \* 3 expect_output: '12' match_type: contains auto_fixed: shell_execution - name: '5. POSIX ARITHMETIC: expr division' steps: - send_line: expr 15 / 3 expect_output: '5' match_type: contains auto_fixed: shell_execution - name: '6. POSIX REDIRECTION: output redirect' steps: - send_line: echo test > /tmp/posix_test_out; cat /tmp/posix_test_out expect_output: test match_type: contains - name: '6. POSIX REDIRECTION: append redirect' steps: - send_line: echo line1 > /tmp/posix_test_app; echo line2 >> /tmp/posix_test_app; wc -l < /tmp/posix_test_app expect_output: '2' match_type: contains - name: '6. POSIX REDIRECTION: input redirect' steps: - send_line: echo input > /tmp/posix_test_in; cat < /tmp/posix_test_in expect_output: input match_type: contains - name: '6. POSIX REDIRECTION: stderr redirect' steps: - send_line: ls /nonexistent 2>&1 | grep -c 'cannot access\|No such\|not found' expect_output: '1' match_type: contains - name: '7. POSIX PIPELINES: simple pipe' steps: - send_line: echo hello | cat expect_output: hello match_type: contains - name: '7. POSIX PIPELINES: two-stage pipe' steps: - send_line: echo test | cat | tr t T expect_output: TesT match_type: contains - name: '7. POSIX PIPELINES: pipe with filter' steps: - send_line: printf 'a\nb\nc\n' | grep b expect_output: b match_type: contains auto_fixed: shell_execution - name: '8. POSIX TEST COMMAND: test -f file (exit code)' steps: - send_line: touch /tmp/posix_test_file && test -f /tmp/posix_test_file - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test -d directory (exit code)' steps: - send_line: test -d /tmp - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test -n nonempty (exit code)' steps: - send_line: test -n 'hello' - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test -z empty (exit code)' steps: - send_line: test -z '' - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test string = (exit code)' steps: - send_line: test 'hello' = 'hello' - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test string != (exit code)' steps: - send_line: test 'hello' != 'world' - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test number -eq (exit code)' steps: - send_line: test 5 -eq 5 - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test number -ne (exit code)' steps: - send_line: test 5 -ne 3 - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test number -gt (exit code)' steps: - send_line: test 5 -gt 3 - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test number -ge (exit code)' steps: - send_line: test 5 -ge 5 - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test number -lt (exit code)' steps: - send_line: test 3 -lt 5 - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '8. POSIX TEST COMMAND: test number -le (exit code)' steps: - send_line: test 3 -le 3 - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '9. POSIX CONDITIONALS: if true' steps: - send_line: if true; then echo yes; fi expect_output: 'yes' match_type: contains auto_fixed: shell_execution - name: '9. POSIX CONDITIONALS: if false else' steps: - send_line: if false; then echo no; else echo yes; fi expect_output: 'yes' match_type: contains auto_fixed: shell_execution - name: '9. POSIX CONDITIONALS: if-elif-else' steps: - send_line: X=2; if [ $X -eq 1 ]; then echo one; elif [ $X -eq 2 ]; then echo two; else echo other; fi expect_output: two match_type: contains - name: '10. POSIX LOOPS: for loop' steps: - send_line: for i in a b c; do echo $i; done expect_output: a match_type: contains auto_fixed: shell_execution - name: '10. POSIX LOOPS: while loop' steps: - send_line: i=3; while [ $i -gt 0 ]; do echo $i; i=$((i - 1)); done expect_output: '3' match_type: contains auto_fixed: shell_execution - name: '10. POSIX LOOPS: until loop' steps: - send_line: i=1; until [ $i -gt 3 ]; do echo $i; i=$((i + 1)); done expect_output: '1' match_type: contains auto_fixed: shell_execution - name: '11. POSIX CASE STATEMENT: case exact match' steps: - send_line: x=2; case $x in 1) echo one;; 2) echo two;; esac expect_output: two match_type: contains auto_fixed: shell_execution - name: '11. POSIX CASE STATEMENT: case pattern match' steps: - send_line: x=hello; case $x in h*) echo h_prefix;; esac expect_output: h_prefix match_type: contains auto_fixed: shell_execution - name: '11. POSIX CASE STATEMENT: case default' steps: - send_line: x=z; case $x in a) echo a;; b) echo b;; *) echo default;; esac expect_output: default match_type: contains auto_fixed: shell_execution - name: '11. POSIX CASE STATEMENT: case multiple patterns' steps: - send_line: x=b; case $x in a|b|c) echo abc;; *) echo other;; esac expect_output: abc match_type: contains auto_fixed: shell_execution - name: '12. POSIX FUNCTIONS: simple function' steps: - send_line: func() { echo hello; }; func expect_output: hello match_type: contains auto_fixed: shell_execution - name: '12. POSIX FUNCTIONS: function with args' steps: - send_line: func() { echo $1 $2; }; func foo bar expect_output: foo bar match_type: contains auto_fixed: shell_execution - name: '12. POSIX FUNCTIONS: function return' steps: - send_line: func() { return 42; }; func; echo $? expect_output: '42' match_type: contains auto_fixed: shell_execution - name: '12. POSIX FUNCTIONS: function \$# args' steps: - send_line: func() { echo $#; }; func a b c expect_output: '3' match_type: contains auto_fixed: shell_execution - name: '13. POSIX SPECIAL VARIABLES: \$? exit status' steps: - send_line: true; echo $? expect_output: '0' match_type: contains auto_fixed: shell_execution - name: '13. POSIX SPECIAL VARIABLES: \$? after false' steps: - send_line: false; echo $? expect_output: '1' match_type: contains auto_fixed: shell_execution - name: '13. POSIX SPECIAL VARIABLES: \$# argument count' steps: - send_line: set -- a b c; echo $# expect_output: '3' match_type: contains auto_fixed: shell_execution - name: '13. POSIX SPECIAL VARIABLES: \$@ all arguments' steps: - send_line: set -- a b c; echo $@ expect_output: a b c match_type: contains auto_fixed: shell_execution - name: '13. POSIX SPECIAL VARIABLES: \$* all arguments' steps: - send_line: set -- a b c; echo $* expect_output: a b c match_type: contains auto_fixed: shell_execution - name: '13. POSIX SPECIAL VARIABLES: \$0 script name' steps: - send_line: echo $0 | grep -c sh expect_output: '1' match_type: contains auto_fixed: shell_execution - name: '14. POSIX LOGICAL OPERATORS: true && true (exit code)' steps: - send_line: true && true - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '14. POSIX LOGICAL OPERATORS: true && false (exit code)' steps: - send_line: true && false - send_line: echo "EXIT=$?" expect_output: EXIT=1 match_type: contains - name: '14. POSIX LOGICAL OPERATORS: false || true (exit code)' steps: - send_line: false || true - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '14. POSIX LOGICAL OPERATORS: false || false (exit code)' steps: - send_line: false || false - send_line: echo "EXIT=$?" expect_output: EXIT=1 match_type: contains - name: '14. POSIX LOGICAL OPERATORS: command && echo' steps: - send_line: true && echo success expect_output: success match_type: contains auto_fixed: shell_execution - name: '14. POSIX LOGICAL OPERATORS: command || echo' steps: - send_line: false || echo fallback expect_output: fallback match_type: contains auto_fixed: shell_execution - name: '14. POSIX LOGICAL OPERATORS: ! negation' steps: - send_line: '! false && echo negated' expect_output: negated match_type: contains auto_fixed: shell_execution - name: '15. POSIX QUOTING: single quote literal' steps: - send_line: echo '$VAR' expect_output: \$VAR match_type: contains auto_fixed: shell_execution - name: '15. POSIX QUOTING: double quote expand' steps: - send_line: VAR=test; echo "$VAR" expect_output: test match_type: contains - name: '15. POSIX QUOTING: escape in double' steps: - send_line: echo "test$var" expect_output: test match_type: contains auto_fixed: shell_execution - name: '15. POSIX QUOTING: backslash escape' steps: - send_line: echo test\ word expect_output: test word match_type: contains - name: '16. POSIX SUBSHELLS: subshell grouping' steps: - send_line: (echo a; echo b) | wc -l expect_output: '2' match_type: contains - name: '16. POSIX SUBSHELLS: subshell var isolation' steps: - send_line: (VAR=inner; echo $VAR); echo $VAR expect_output: inner match_type: contains auto_fixed: shell_execution - name: '17. POSIX COMPOUND COMMANDS: command grouping {}' steps: - send_line: '{ echo a; echo b; } | wc -l' expect_output: '2' match_type: contains - name: '17. POSIX COMPOUND COMMANDS: command list ;' steps: - send_line: echo a; echo b expect_output: a match_type: contains - name: '19. POSIX WORD EXPANSION ORDER: expansion order' steps: - send_line: VAR='a b'; echo $VAR expect_output: a b match_type: contains auto_fixed: shell_execution - name: '19. POSIX WORD EXPANSION ORDER: quoted expansion' steps: - send_line: VAR="a b"; echo "$VAR" expect_output: a b match_type: contains - name: '20. POSIX PATHNAME EXPANSION (GLOBBING): glob * pattern' steps: - send_line: ls /tmp/posix_test_glob/*.txt 2>/dev/null | wc -l expect_output: '[0-9]+' match_type: regex - name: '20. POSIX PATHNAME EXPANSION (GLOBBING): glob ? pattern' steps: - send_line: ls /tmp/posix_test_glob/?.txt 2>/dev/null | wc -l expect_output: '[0-9]+' match_type: regex - name: '20. POSIX PATHNAME EXPANSION (GLOBBING): glob [abc] pattern' steps: - send_line: ls /tmp/posix_test_glob/[ab].txt 2>/dev/null | wc -l expect_output: '[0-9]+' match_type: regex - name: '21. POSIX FIELD SPLITTING (IFS): default IFS' steps: - send_line: VAR='a b c'; set -- $VAR; echo $# expect_output: '3' match_type: contains auto_fixed: shell_execution - name: '21. POSIX FIELD SPLITTING (IFS): custom IFS' steps: - send_line: IFS=:; VAR='a:b:c'; set -- $VAR; echo $1 expect_output: a match_type: contains auto_fixed: shell_execution - name: '22. POSIX EXIT STATUS: true exit status (exit code)' steps: - send_line: 'true' - send_line: echo "EXIT=$?" expect_output: EXIT=0 match_type: contains - name: '22. POSIX EXIT STATUS: false exit status (exit code)' steps: - send_line: 'false' - send_line: echo "EXIT=$?" expect_output: EXIT=1 match_type: contains - name: '22. POSIX EXIT STATUS: command not found (exit code)' steps: - send_line: nonexistent_command_xyz 2>/dev/null - send_line: echo "EXIT=$?" expect_output: EXIT=127 match_type: contains - name: '22. POSIX EXIT STATUS: return from function (exit code)' steps: - send_line: func() { return 3; }; func - send_line: echo "EXIT=$?" expect_output: EXIT=3 match_type: contains - name: '23. POSIX SET BUILTIN: set positional' steps: - send_line: set -- a b c; echo $1 $2 $3 expect_output: a match_type: contains auto_fixed: shell_execution - name: '23. POSIX SET BUILTIN: set shift' steps: - send_line: set -- a b c; shift; echo $1 expect_output: b match_type: contains auto_fixed: shell_execution - name: '23. POSIX SET BUILTIN: set shift n' steps: - send_line: set -- a b c d; shift 2; echo $1 expect_output: c match_type: contains auto_fixed: shell_execution - name: '24. POSIX EXPORT: export variable' steps: - send_line: export VAR=test; sh -c 'echo $VAR' expect_output: test match_type: contains auto_fixed: shell_execution - name: '25. POSIX READONLY: readonly assignment (exit code)' steps: - send_line: readonly VAR=test; VAR=new 2>/dev/null - send_line: echo "EXIT=$?" expect_output: EXIT=1 match_type: contains