52 lines
1.2 KiB
YAML
52 lines
1.2 KiB
YAML
name: "Builtins: exec"
|
|
cases:
|
|
- name: "Exec an invalid path"
|
|
ignore_stderr: true
|
|
stdin: |
|
|
exec /some/nonexistent/path
|
|
|
|
- name: "Exec with no arguments"
|
|
stdin: |
|
|
pid=$$
|
|
exec
|
|
[[ "${pid}" == "$$" ]] || echo "PID changed"
|
|
|
|
- name: "Exec with no arguments and redirection for new fd"
|
|
stdin: |
|
|
exec 3>some-file.txt
|
|
echo "Hello, fd 3!" >&3
|
|
|
|
- name: "Exec with no arguments and redirection of stderr"
|
|
stdin: |
|
|
exec 2>/dev/null
|
|
|
|
# Do something that should display an error to stderr
|
|
source /non-existent
|
|
|
|
- name: "Exec with no arguments and redirection in a script"
|
|
test_files:
|
|
- path: "script.sh"
|
|
contents: |
|
|
exec 2>output-file.txt
|
|
echo hi >&2
|
|
args: ["./script.sh"]
|
|
|
|
- name: "Exec a command"
|
|
stdin: |
|
|
exec $0 -c 'echo "In child shell"'
|
|
echo "This is never reached"
|
|
|
|
- name: "exec without -c"
|
|
stdin: |
|
|
export myvar=value
|
|
exec $0 -c 'echo "myvar: ${myvar}"'
|
|
|
|
- name: "exec -c"
|
|
stdin: |
|
|
export myvar=value
|
|
exec -c $0 -c 'echo "myvar: ${myvar}"'
|
|
|
|
- name: "exec -a"
|
|
stdin: |
|
|
exec -a shellname $0 -c 'echo "0: $0"'
|