xref: /freebsd/bin/sh/tests/builtins/builtin1.0 (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1
2failures=0
3
4check() {
5	if ! eval "[ $* ]"; then
6		echo "Failed: $*"
7		: $((failures += 1))
8	fi
9}
10
11builtin : || echo "Bad return code at $LINENO"
12builtin true || echo "Bad return code at $LINENO"
13builtin ls 2>/dev/null && echo "Bad return code at $LINENO"
14check '"$(builtin pwd)" = "$(pwd)"'
15check '-z "$(builtin :)"'
16check '-z "$(builtin true)"'
17check '-z "$( (builtin nosuchtool) 2>/dev/null)"'
18check '-z "$(builtin nosuchtool 2>/dev/null)"'
19check '-z "$(builtin nosuchtool 2>/dev/null; :)"'
20check '-z "$( (builtin ls) 2>/dev/null)"'
21check '-z "$(builtin ls 2>/dev/null)"'
22check '-z "$(builtin ls 2>/dev/null; :)"'
23check '-n "$( (builtin nosuchtool) 2>&1)"'
24check '-n "$(builtin nosuchtool 2>&1)"'
25check '-n "$(builtin nosuchtool 2>&1; :)"'
26check '-n "$( (builtin ls) 2>&1)"'
27check '-n "$(builtin ls 2>&1)"'
28check '-n "$(builtin ls 2>&1; :)"'
29
30exit $((failures > 0))
31