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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 04, 2017 at 04:59:02PM +0300, Jani Nikula wrote:
> Similar to git. Don't allow override of internal commands though.

git did this, and then went to a slightly different version because
git<Tab> doesn't complete to a space due to the various git-foo commands
in path. Imo the right way to do this is to have a libexec/ subdir,
complete just those (and switch the completion to recognize them), i.e.
git foo would run maintainer-tools/libexec/git-foo or maybe
maintainer-tools/git-foo. But not depend upon git-foo being in your path
(because that is really annoying to me).

Other cleanup patches are all acked.
-Daniel
> 
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
> ---
>  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
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux