From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [dim PATCH 1/2] dim: add -s option to treat unset variables as an error
Date: Tue, 28 Mar 2017 12:51:25 +0300 [thread overview]
Message-ID: <1490694686-19686-1-git-send-email-jani.nikula@intel.com> (raw)
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
next reply other threads:[~2017-03-28 9:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 9:51 Jani Nikula [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490694686-19686-1-git-send-email-jani.nikula@intel.com \
--to=jani.nikula@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox