opnsense-src/bin/sh/tests/expansion/question2.0
Jilles Tjoelker 468ed39612 sh: Fix ${param?} default error message
If word in ${param?word} is missing, the shell shall write a default error
message. So expanding ${param?} when param is not set should write an error
message like

sh: param: parameter not set

This was broken by r316417.

PR:		233585
2018-11-28 20:03:53 +00:00

11 lines
176 B
Text

# $FreeBSD$
unset dummyvar
msg=`(: ${dummyvar?}) 2>&1`
r=$?
[ "$r" != 0 ] && case $msg in
*dummyvar?* | *?dummyvar*) : ;;
*)
printf 'Bad message: [%s]\n' "$msg"
exit 1
esac