mirror of
https://github.com/opnsense/src.git
synced 2026-03-31 15:05:17 -04:00
Although "--" historically has not been required to be recognized for certain special builtins that do not take options in POSIX, some other implementations recognize options for them, requiring scripts to use "--" or avoid operands starting with "-". Operands starting with "-" can be avoided with eval by prepending a space, and cannot occur with break, continue, exit, return and shift as they only take numbers, nor with times as it does not take operands. With . and exec, avoiding "-" is not so easy as it may require reimplementing the PATH search; therefore the current proposal for POSIX is to require recognition of "--" for them. We continue to accept other strings starting with "-" as operands to . and exec, and also "--" if it is alone to . (which would otherwise be invalid anyway).
21 lines
360 B
Text
21 lines
360 B
Text
# $FreeBSD$
|
|
|
|
failures=
|
|
failure() {
|
|
echo "Error at line $1" >&2
|
|
failures=x$failures
|
|
}
|
|
|
|
T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) || exit
|
|
trap 'rm -rf $T' 0
|
|
cd $T || exit 3
|
|
unset x
|
|
echo 'x=2' >testscript
|
|
. -- ./testscript
|
|
[ "$x" = 2 ] || failure $LINENO
|
|
cd / || exit 3
|
|
x=1
|
|
PATH=$T:$PATH . -- testscript
|
|
[ "$x" = 2 ] || failure $LINENO
|
|
|
|
test -z "$failures"
|