public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [dim PATCH 1/2] dim: add -s option to treat unset variables as an error
@ 2017-03-28  9:51 Jani Nikula
  2017-03-28  9:51 ` [dim PATCH 2/2] dim: start using ${1:?$usage} to refer to arguments Jani Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2017-03-28  9:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Use -s for "strict" to 'set -u'. Fix the variable references to not fail
before subcommand call. The goal is to unconditionally 'set -u' at the
top, but it can't be done in one go, so add a way to test drive first.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/dim b/dim
index 99120b82513e..3e10f360d482 100755
--- a/dim
+++ b/dim
@@ -145,7 +145,7 @@ function pause
 	echo
 }
 
-while getopts hdfi opt; do
+while getopts hdfis opt; do
 	case "$opt" in
 		d)
 			DRY_RUN=--dry-run
@@ -160,6 +160,11 @@ while getopts hdfi opt; do
 		h)
 			HELP=1
 			;;
+		s)
+			# FIXME: transitional, do unconditionally at the top
+			# when there are no more errors about unbound variables
+			set -u
+			;;
 		*)
 			echoerr "See '$dim help' for more information."
 			exit
@@ -180,7 +185,7 @@ fi
 #
 
 # Make sure we use 'dim_foo' within dim instead of 'dim foo'.
-if [[ -n "$__dim_running" ]]; then
+if [[ -n "${__dim_running:-}" ]]; then
 	echoerr "INTERNAL ERROR: do not recurse back to dim"
 	exit 1
 fi
@@ -1829,7 +1834,7 @@ function dim_usage
 
 # dim subcommand aliases (with bash 4.3+)
 if ! declare -n subcmd=dim_alias_${subcommand//-/_} &> /dev/null || \
-		test -z "$subcmd"; then
+		test -z "${subcmd:-}"; then
 	subcmd="$subcommand"
 fi
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-28 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-28  9:51 [dim PATCH 1/2] dim: add -s option to treat unset variables as an error Jani Nikula
2017-03-28  9:51 ` [dim PATCH 2/2] dim: start using ${1:?$usage} to refer to arguments Jani Nikula
2017-03-28 14:33   ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox