Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2022 16:47:43 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 74a790b760a9 - stable/13 - newvers.sh: Don't use return to exit.
Message-ID:  <202207131647.26DGlhUs052304@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=74a790b760a90ed125e1732fc02ab8b3eff9cb75

commit 74a790b760a90ed125e1732fc02ab8b3eff9cb75
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-06-14 17:51:39 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-07-13 16:20:34 +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
    
    (cherry picked from commit 6ab35c78fb5af66d586d4846e2d81e020331ad3f)
---
 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 0dfb0a455e55..48320ce1b7c3 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207131647.26DGlhUs052304>