aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-06-14 17:51:39 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2022-06-14 17:51:39 +0000
commit6ab35c78fb5af66d586d4846e2d81e020331ad3f (patch)
tree3df2c638a52de67f62e6fd5613249467a3018d6d
parent628a4156a761d3daac8a4adc0e675c6e6064fd5a (diff)
downloadsrc-6ab35c78fb5af66d586d4846e2d81e020331ad3f.tar.gz
src-6ab35c78fb5af66d586d4846e2d81e020331ad3f.zip
newvers.sh: Don't use return to exit.
Commit acfb506b3d00 replaced an exit 0 when using -V with a return instead. FreeBSD's sh treats a return outside of a function like exit, but this is a non-portable extension. Other Bourne shells only permit return to be used within a function and continue execution (possibly with a warning). To fix, don't reuse VARS_ONLY (which is intended to be set by other scripts before sourcing newvers.sh directly) and instead use a new variable (VARS_ONLY_EXIT) to restore the use of exit for the non-sourced case. Reviewed by: emaste Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D35481
-rw-r--r--sys/conf/newvers.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 84c498580d4e..f3c437269026 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -127,7 +127,7 @@ while getopts crRvV: opt; do
v=$OPTARG
eval val=\$${v}
echo ${v}=\"${val}\"
- VARS_ONLY=1
+ VARS_ONLY_EXIT=1
;;
esac
done
@@ -137,6 +137,10 @@ shift $((OPTIND - 1))
# included.
[ -n "$VARS_ONLY" ] && return 0
+# VARS_ONLY_EXIT means no files should be generated, only the value of
+# variables are being output.
+[ -n "$VARS_ONLY_EXIT" ] && exit 0
+
#
# findvcs dir
# Looks up directory dir at world root and up the filesystem