dim: handle missing declare -n option gracefully
PATCH 1/2 dim: handle missing declare -n option gracefully
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 <[email protected]>
Reported-by Gerd Hoffmann <[email protected]>
Signed-off-by Jani Nikula <[email protected]>
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -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
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 dim: document how to define subcommand aliases
Cc Gerd Hoffmann <[email protected]>
Signed-off-by Jani Nikula <[email protected]>
--- dim.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
dim.rst +10 -1
@@ -330,9 +330,10 @@ Run the given command in all active workdirs including the main repository under list-aliases ------------ - List all aliases for the subcommand names. Useful for autocompletion scripts. +See \$dim_alias_<alias> under ENVIRONMENT below on how to define aliases. + list-branches -------------
@@ -401,6 +402,14 @@ DIM_TEMPLATE_SIGNATURE ---------------------- Path to a file containing a signature template for pull request mails. +dim_alias_<alias> +----------------- +Make **<alias>** an alias for the subcommand defined as the value. For example, +`dim_alias_ub=update-branches`. There are some built-in aliases. Aliases can be +listed using the **list-aliases** subcommand. + +The alias functionality requires **bash(1)** version 4.3 or later to work. + CONTRIBUTING ============
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx