dim: do not bail out if the script is not up-to-date
PATCH 1/4 dim: do not bail out if the script is not up-to-date
It's rather obnoxious to exit in the middle of something just because you haven't updated the script. Only issue a warning.
--- dim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
dim +4 -4
@@ -289,18 +289,18 @@ function dim_uptodate if [[ ! -e "$using" ]]; then echoerr "could not figure out the version being used ($using)." - exit 1 + return 1 fi if [[ ! -e "$DIM_PREFIX/maintainer-tools/.git" ]]; then echoerr "could not find the upstream repo for $dim." - exit 1 + return 1 fi if ! git --git-dir=$DIM_PREFIX/maintainer-tools/.git show "@{upstream}:dim" |\ diff "$using" - >& /dev/null; then echoerr "not running upstream version of the script." - exit 1 + return 1 fi }
@@ -334,7 +334,7 @@ function git_branch_exists # branch } if [[ "$(($(date +%s) % 100))" -eq "0" ]] ; then - dim_uptodate + dim_uptodate || true fi # get message id from file
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 dim: move dim update check near the end
Reserve the middle part of the script for function and alias definitions only.
--- dim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
dim +9 -4
@@ -204,6 +204,10 @@ if [ "$subcommand" != "setup" ] && [ "$subcommand" != "help" ] && [ "$subcommand fi # +# Only function and alias definitions until the subcommand handling at the end. +# + +# # Variable naming convetion: # # repo:
@@ -333,10 +337,6 @@ function git_branch_exists # branch fi } -if [[ "$(($(date +%s) % 100))" -eq "0" ]] ; then - dim_uptodate || true -fi - # get message id from file # $1 = file message_get_id ()
@@ -1893,6 +1893,11 @@ function dim_usage echo "See '$dim help' for more information." } +# occasional check for dim updates +if [[ "$(($(date +%s) % 100))" -eq "0" ]] ; then + dim_uptodate || true +fi + # dim subcommand aliases (with bash 4.3+) if ! declare -n subcmd=dim_alias_${subcommand//-/_} &> /dev/null || \ test -z "${subcmd:-}"; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 dim: move helper functions above command line options handling
In reply to Jani NikulaThe functions have been added kind of in the middle at some point. Clean it up.
--- dim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
dim +10 -10
@@ -114,16 +114,6 @@ function read_integration_config } read_integration_config -# -# Command line options. -# - -DRY_RUN= -INTERACTIVE= -DRY= -FORCE= -HELP= - function echoerr { echo "$dim: $*" >&2
@@ -145,6 +135,16 @@ function pause echo } +# +# Command line options. +# + +DRY_RUN= +INTERACTIVE= +DRY= +FORCE= +HELP= + while getopts hdfis opt; do case "$opt" in d)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 dim: run executables in $PATH named dim-subcommand as dim subcommands
In reply to Jani NikulaSimilar to git. Don't allow override of internal commands though.
--- dim | 6 ++++++ 1 file changed, 6 insertions(+)
dim +6 -0
@@ -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
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
Quoted 1 line · Jani Nikula
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
Quoted 30 lines
Signed-off-by Jani Nikula <[email protected]>--- dim | 6 ++++++ 1 file changed, 6 insertions(+)dim +6
-0@@ -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 1Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
Quoted 10 lines · Daniel Vetter
Quoted 1 line · Jani Nikula
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).
Agreed on the annoyance. But libexec is annoying too because it precludes the user from adding their own extensions in $PATH. An alternative is to mandate a *different* prefix for external dim commands, for example external-dim-foo.
I'm not hung up on this patch anyway, it was just a quick idea in case we want to add largish related tools without cluttering the already pretty big dim source.
Quoted 1 line
Other cleanup patches are all acked.
Pushed those, thanks.
BR,
Jani.
Quoted 31 lines
-Daniel
Quoted 30 lines
Signed-off-by Jani Nikula <[email protected]>--- dim | 6 ++++++ 1 file changed, 6 insertions(+)dim +6
-0@@ -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 1Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
Quoted 12 lines · Jani Nikula
Quoted 10 lines · Daniel Vetter
Quoted 1 line · Jani Nikula
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).
Quoted 8 lines
Agreed on the annoyance. But libexec is annoying too because it precludes the user from adding their own extensions in $PATH. An alternative is to mandate a *different* prefix for external dim commands, for example external-dim-foo.
I'm not hung up on this patch anyway, it was just a quick idea in case we want to add largish related tools without cluttering the already pretty big dim source.
You can add the libexec path (or well, DIM_SRC/maintainer-tools) and get both. Or do you mean adding your own extensions, not in the upstream maintainer-tools? I'd say for that case some pressure to get tools merged into upstream would be good :-)
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx