Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Jun 2018 03:33:30 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335277 - head/usr.sbin/sysrc
Message-ID:  <201806170333.w5H3XUv7000479@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Sun Jun 17 03:33:29 2018
New Revision: 335277
URL: https://svnweb.freebsd.org/changeset/base/335277

Log:
  sysrc(8): Exit with failure on API error
  
  Fix exit status when f_sysrc_set() fails. Errors in the underlying API
  provided by bsdconfig(8) -- /usr/share/bsdconfig/sysrc.subr -- were not
  being communicated back to the command-line. This was affecting ansible
  modules using sysrc as they were not able to accurately test for error.
  
  PR:		bin/211448
  Reported by:	Christian Schwarz <me@cschwarz.com>
  MFC after:	3 days
  X-MFC-to:	stable/11
  Sponsored by:	Smule, Inc.

Modified:
  head/usr.sbin/sysrc/sysrc

Modified: head/usr.sbin/sysrc/sysrc
==============================================================================
--- head/usr.sbin/sysrc/sysrc	Sun Jun 17 03:18:56 2018	(r335276)
+++ head/usr.sbin/sysrc/sysrc	Sun Jun 17 03:33:29 2018	(r335277)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #-
-# Copyright (c) 2010-2016 Devin Teske
+# Copyright (c) 2010-2018 Devin Teske
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
 #
 # Version information
 #
-SYSRC_VERSION="7.1 Feb-2,2016"
+SYSRC_VERSION="7.2 Jun-16,2018"
 
 #
 # Options
@@ -854,7 +854,7 @@ while [ $# -gt 0 ]; do
 		#
 		if [ ! "$SHOW_VALUE" ]; then
 			echo "$NAME"
-			f_sysrc_set "$NAME" "$new"
+			f_sysrc_set "$NAME" "$new" || status=$FAILURE
 		else
 			if f_sysrc_set "$NAME" "$new"; then
 				if [ "$SHOW_FILE" ]; then
@@ -866,6 +866,8 @@ while [ $# -gt 0 ]; do
 				echo -n "$before${SHOW_EQUALS:+\" #}"
 				echo -n " -> ${SHOW_EQUALS:+\"}$after"
 				echo "${SHOW_EQUALS:+\"}"
+			else
+				status=$FAILURE
 			fi
 		fi
 		;;



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