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