[Intel-gfx] [dim PATCH 1/2] dim: handle missing declare -n option gracefully

Jani Nikula jani.nikula at intel.com
Tue Jan 31 09:42:29 UTC 2017


The declare -n option was added in bash 4.3. Handle missing -n
gracefully, at the expense of losing dim alias functionality.

Cc: Gerd Hoffmann <kraxel at redhat.com>
Reported-by: Gerd Hoffmann <kraxel at redhat.com>
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 dim | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/dim b/dim
index 9500a9df102a..20eac8c58c58 100755
--- a/dim
+++ b/dim
@@ -1598,9 +1598,9 @@ function dim_usage
 	echo "See '$dim help' for more information."
 }
 
-# dim subcommand aliases
-declare -n subcmd=dim_alias_${subcommand//-/_}
-if [ -z "$subcmd" ]; then
+# dim subcommand aliases (with bash 4.3+)
+if ! declare -n subcmd=dim_alias_${subcommand//-/_} &> /dev/null || \
+		test -z "$subcmd"; then
 	subcmd="$subcommand"
 fi
 
-- 
2.1.4



More information about the Intel-gfx mailing list