[Intel-gfx] [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands

Jani Nikula jani.nikula at intel.com
Tue Apr 4 13:59:02 UTC 2017


Similar to git. Don't allow override of internal commands though.

Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 dim | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dim b/dim
index 45dc07cd0426..85da1542087e 100755
--- a/dim
+++ b/dim
@@ -1907,6 +1907,12 @@ fi
 # look up the function by the subcommand name
 subcmd_func=dim_${subcmd//-/_}
 if ! declare -f $subcmd_func >/dev/null; then
+	# look up dim-subcommand in PATH, and run it
+	ext_subcmd=${subcmd_func//_/-}
+	if hash $ext_subcmd 2>/dev/null; then
+		exec $ext_subcmd "$@"
+	fi
+
 	echoerr "'$subcommand' is not a dim command."
 	dim_usage
 	exit 1
-- 
2.1.4



More information about the Intel-gfx mailing list