git: 6ab35c78fb5a - main - newvers.sh: Don't use return to exit.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 14 Jun 2022 17:52:23 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=6ab35c78fb5af66d586d4846e2d81e020331ad3f

commit 6ab35c78fb5af66d586d4846e2d81e020331ad3f
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-06-14 17:51:39 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-06-14 17:51:39 +0000

    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
---
 sys/conf/newvers.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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