xref: /freebsd/bin/sh/tests/builtins/builtin1.0 (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
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