* [dim PATCH 1/4] dim: do not bail out if the script is not up-to-date
@ 2017-04-04 13:58 Jani Nikula
2017-04-04 13:59 ` [dim PATCH 2/4] dim: move dim update check near the end Jani Nikula
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jani Nikula @ 2017-04-04 13:58 UTC (permalink / raw)
To: intel-gfx; +Cc: jani.nikula
It's rather obnoxious to exit in the middle of something just because
you haven't updated the script. Only issue a warning.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
dim | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dim b/dim
index 33d5fd3c0303..8671bcb84845 100755
--- a/dim
+++ b/dim
@@ -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
--
2.1.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dim PATCH 2/4] dim: move dim update check near the end
2017-04-04 13:58 [dim PATCH 1/4] dim: do not bail out if the script is not up-to-date Jani Nikula
@ 2017-04-04 13:59 ` Jani Nikula
2017-04-04 13:59 ` [dim PATCH 3/4] dim: move helper functions above command line options handling Jani Nikula
2017-04-04 13:59 ` [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands Jani Nikula
2 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2017-04-04 13:59 UTC (permalink / raw)
To: intel-gfx; +Cc: jani.nikula
Reserve the middle part of the script for function and alias definitions
only.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
dim | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/dim b/dim
index 8671bcb84845..a76e4e4d3f09 100755
--- a/dim
+++ b/dim
@@ -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
--
2.1.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dim PATCH 3/4] dim: move helper functions above command line options handling
2017-04-04 13:58 [dim PATCH 1/4] dim: do not bail out if the script is not up-to-date Jani Nikula
2017-04-04 13:59 ` [dim PATCH 2/4] dim: move dim update check near the end Jani Nikula
@ 2017-04-04 13:59 ` Jani Nikula
2017-04-04 13:59 ` [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands Jani Nikula
2 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2017-04-04 13:59 UTC (permalink / raw)
To: intel-gfx; +Cc: jani.nikula
The functions have been added kind of in the middle at some point. Clean
it up.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
dim | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/dim b/dim
index a76e4e4d3f09..45dc07cd0426 100755
--- a/dim
+++ b/dim
@@ -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)
--
2.1.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
2017-04-04 13:58 [dim PATCH 1/4] dim: do not bail out if the script is not up-to-date Jani Nikula
2017-04-04 13:59 ` [dim PATCH 2/4] dim: move dim update check near the end Jani Nikula
2017-04-04 13:59 ` [dim PATCH 3/4] dim: move helper functions above command line options handling Jani Nikula
@ 2017-04-04 13:59 ` Jani Nikula
2017-04-04 15:03 ` Daniel Vetter
2 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2017-04-04 13:59 UTC (permalink / raw)
To: intel-gfx; +Cc: jani.nikula
Similar to git. Don't allow override of internal commands though.
Signed-off-by: Jani Nikula <jani.nikula@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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
2017-04-04 13:59 ` [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands Jani Nikula
@ 2017-04-04 15:03 ` Daniel Vetter
2017-04-05 7:28 ` Jani Nikula
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2017-04-04 15:03 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx
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@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
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
2017-04-04 15:03 ` Daniel Vetter
@ 2017-04-05 7:28 ` Jani Nikula
2017-04-05 9:12 ` Daniel Vetter
0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2017-04-05 7:28 UTC (permalink / raw)
To: Daniel Vetter; +Cc: intel-gfx
On Tue, 04 Apr 2017, Daniel Vetter <daniel@ffwll.ch> wrote:
> 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).
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.
> Other cleanup patches are all acked.
Pushed those, thanks.
BR,
Jani.
> -Daniel
>>
>> Signed-off-by: Jani Nikula <jani.nikula@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
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands
2017-04-05 7:28 ` Jani Nikula
@ 2017-04-05 9:12 ` Daniel Vetter
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2017-04-05 9:12 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx
On Wed, Apr 05, 2017 at 10:28:06AM +0300, Jani Nikula wrote:
> On Tue, 04 Apr 2017, Daniel Vetter <daniel@ffwll.ch> wrote:
> > 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).
>
> 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
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-04-05 9:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 13:58 [dim PATCH 1/4] dim: do not bail out if the script is not up-to-date Jani Nikula
2017-04-04 13:59 ` [dim PATCH 2/4] dim: move dim update check near the end Jani Nikula
2017-04-04 13:59 ` [dim PATCH 3/4] dim: move helper functions above command line options handling Jani Nikula
2017-04-04 13:59 ` [dim PATCH 4/4] dim: run executables in $PATH named dim-subcommand as dim subcommands Jani Nikula
2017-04-04 15:03 ` Daniel Vetter
2017-04-05 7:28 ` Jani Nikula
2017-04-05 9:12 ` Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.