* [PATCH] scripts/tags.sh: Exit gracefully if *tags tool not found
@ 2016-04-24 16:42 Eugeniu Rosca
2016-04-25 12:35 ` Michal Marek
0 siblings, 1 reply; 5+ messages in thread
From: Eugeniu Rosca @ 2016-04-24 16:42 UTC (permalink / raw)
To: mmarek, mpe, kirill.shutemov, naveen.n.rao, akpm, sboyd,
paul.gortmaker
Cc: linux-kbuild, Eugeniu Rosca
If the needed host utility is not found, current behavior is:
$> make cscope
GEN cscope
./scripts/tags.sh: line 140: cscope: command not found
$> make gtags
GEN gtags
./scripts/tags.sh: line 145: gtags: command not found
$> make tags
GEN tags
xargs: ctags: No such file or directory
sed: can't read tags: No such file or directory
Makefile:1509: recipe for target 'tags' failed
make: *** [tags] Error 2
$> make TAGS
GEN TAGS
xargs: etags: No such file or directory
sed: can't read TAGS: No such file or directory
Makefile:1509: recipe for target 'TAGS' failed
make: *** [TAGS] Error 2
This patch allows to exit gracefully in such a situation:
$> make cscope
GEN cscope
cscope - not installed?
$> make gtags
GEN gtags
gtags - not installed?
$> make tags
GEN tags
ctags - not installed?
$> make TAGS
GEN TAGS
etags - not installed?
Signed-off-by: Eugeniu Rosca <eugeniu.m.rosca@gmail.com>
---
scripts/tags.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/scripts/tags.sh b/scripts/tags.sh
index f72f48f..e7f6125 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -289,6 +289,13 @@ xtags()
fi
}
+# Check if a specific utility is accessible on the host
+tool_exists() {
+ [ -x "$(which $1 2> /dev/null)" ] || \
+ { echo "$1 - not installed?" && return 1; }
+ return 0
+}
+
# Support um (which uses SUBARCH)
if [ "${ARCH}" = "um" ]; then
if [ "$SUBARCH" = "i386" ]; then
@@ -318,20 +325,24 @@ fi
remove_structs=
case "$1" in
"cscope")
+ tool_exists cscope || exit 0
docscope
;;
"gtags")
+ tool_exists gtags || exit 0
dogtags
;;
"tags")
+ tool_exists ctags || exit 0
rm -f tags
xtags ctags
remove_structs=y
;;
"TAGS")
+ tool_exists etags || exit 0
rm -f TAGS
xtags etags
remove_structs=y
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] scripts/tags.sh: Exit gracefully if *tags tool not found
2016-04-24 16:42 [PATCH] scripts/tags.sh: Exit gracefully if *tags tool not found Eugeniu Rosca
@ 2016-04-25 12:35 ` Michal Marek
2016-05-15 13:44 ` Eugeniu Rosca
0 siblings, 1 reply; 5+ messages in thread
From: Michal Marek @ 2016-04-25 12:35 UTC (permalink / raw)
To: Eugeniu Rosca, mpe, kirill.shutemov, naveen.n.rao, akpm, sboyd,
paul.gortmaker
Cc: linux-kbuild
On 2016-04-24 18:42, Eugeniu Rosca wrote:
> If the needed host utility is not found, current behavior is:
>
> $> make cscope
> GEN cscope
> ./scripts/tags.sh: line 140: cscope: command not found
> $> make gtags
> GEN gtags
> ./scripts/tags.sh: line 145: gtags: command not found
> $> make tags
> GEN tags
> xargs: ctags: No such file or directory
> sed: can't read tags: No such file or directory
> Makefile:1509: recipe for target 'tags' failed
> make: *** [tags] Error 2
> $> make TAGS
> GEN TAGS
> xargs: etags: No such file or directory
> sed: can't read TAGS: No such file or directory
> Makefile:1509: recipe for target 'TAGS' failed
> make: *** [TAGS] Error 2
>
> This patch allows to exit gracefully in such a situation:
>
> $> make cscope
> GEN cscope
> cscope - not installed?
> $> make gtags
> GEN gtags
> gtags - not installed?
> $> make tags
> GEN tags
> ctags - not installed?
> $> make TAGS
> GEN TAGS
> etags - not installed?
It should fail if it's unable to create the requested file, though.
Appending '|| exit' to the docscope/dogtags/xtags calls should suffice.
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scripts/tags.sh: Exit gracefully if *tags tool not found
2016-04-25 12:35 ` Michal Marek
@ 2016-05-15 13:44 ` Eugeniu Rosca
2016-05-16 7:06 ` Michal Marek
0 siblings, 1 reply; 5+ messages in thread
From: Eugeniu Rosca @ 2016-05-15 13:44 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild
On Mon, Apr 25, 2016 at 02:35:43PM +0200, Michal Marek wrote:
> On 2016-04-24 18:42, Eugeniu Rosca wrote:
> > If the needed host utility is not found, current behavior is:
> >
> > $> make cscope
> > GEN cscope
> > ./scripts/tags.sh: line 140: cscope: command not found
> > $> make gtags
> > GEN gtags
> > ./scripts/tags.sh: line 145: gtags: command not found
> > $> make tags
> > GEN tags
> > xargs: ctags: No such file or directory
> > sed: can't read tags: No such file or directory
> > Makefile:1509: recipe for target 'tags' failed
> > make: *** [tags] Error 2
> > $> make TAGS
> > GEN TAGS
> > xargs: etags: No such file or directory
> > sed: can't read TAGS: No such file or directory
> > Makefile:1509: recipe for target 'TAGS' failed
> > make: *** [TAGS] Error 2
> >
> > This patch allows to exit gracefully in such a situation:
> >
> > $> make cscope
> > GEN cscope
> > cscope - not installed?
> > $> make gtags
> > GEN gtags
> > gtags - not installed?
> > $> make tags
> > GEN tags
> > ctags - not installed?
> > $> make TAGS
> > GEN TAGS
> > etags - not installed?
>
> It should fail if it's unable to create the requested file, though.
> Appending '|| exit' to the docscope/dogtags/xtags calls should suffice.
>
> Michal
Hi Michal,
Late feedback from my end...
I would kindly ask you to select one of the options provided below:
OPTION 1: Append '|| exit' to the docscope/dogtags/xtags calls.
RESULT: This produces more error messages than with the original script:
$> make cscope
GEN cscope
./scripts/tags.sh: line 140: cscope: command not found
Makefile:1517: recipe for target 'cscope' failed
make: *** [cscope] Error 127
$> make gtags
GEN gtags
./scripts/tags.sh: line 145: gtags: command not found
Makefile:1517: recipe for target 'gtags' failed
make: *** [gtags] Error 127
$> make tags
GEN tags
xargs: ctags: No such file or directory
Makefile:1517: recipe for target 'tags' failed
make: *** [tags] Error 127
$> make TAGS
GEN TAGS
xargs: etags: No such file or directory
Makefile:1517: recipe for target 'TAGS' failed
make: *** [TAGS] Error 127
$>
OPTION 2: Append '|| exit 0' to the docscope/dogtags/xtags calls.
RESULT: Cleaner output, but still without suggesting the root-cause:
$> make cscope
GEN cscope
./scripts/tags.sh: line 140: cscope: command not found
$> make gtags
GEN gtags
./scripts/tags.sh: line 145: gtags: command not found
$> make tags
GEN tags
xargs: ctags: No such file or directory
$> make TAGS
GEN TAGS
xargs: etags: No such file or directory
$>
OPTION 3: Initial patch.
RESULT: Cleaner output, but maybe putting too much infrastructure for
checking against missing utilities?
$> make cscope
GEN cscope
cscope - not installed?
$> make gtags
GEN gtags
gtags - not installed?
$> make tags
GEN tags
ctags - not installed?
$> make TAGS
GEN TAGS
etags - not installed?
OPTION 4: Something else?
RESULT: ?
Best regards,
Eugeniu.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scripts/tags.sh: Exit gracefully if *tags tool not found
2016-05-15 13:44 ` Eugeniu Rosca
@ 2016-05-16 7:06 ` Michal Marek
2016-05-16 13:37 ` [PATCH v2] scripts/tags.sh: Handle missing {c,e,g}tags/cscope utilities Eugeniu Rosca
0 siblings, 1 reply; 5+ messages in thread
From: Michal Marek @ 2016-05-16 7:06 UTC (permalink / raw)
To: Eugeniu Rosca; +Cc: linux-kbuild
On 2016-05-15 15:44, Eugeniu Rosca wrote:
> I would kindly ask you to select one of the options provided below:
>
> OPTION 1: Append '|| exit' to the docscope/dogtags/xtags calls.
> RESULT: This produces more error messages than with the original script:
>
> $> make cscope
> GEN cscope
> ./scripts/tags.sh: line 140: cscope: command not found
> Makefile:1517: recipe for target 'cscope' failed
> make: *** [cscope] Error 127
> [...]
This is the correct behavior because a missing tool is an error.
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] scripts/tags.sh: Handle missing {c,e,g}tags/cscope utilities
2016-05-16 7:06 ` Michal Marek
@ 2016-05-16 13:37 ` Eugeniu Rosca
0 siblings, 0 replies; 5+ messages in thread
From: Eugeniu Rosca @ 2016-05-16 13:37 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, eugeniu.m.rosca
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 0001-scripts-tags.sh-Handle-missing-c-e-g-tags-cscope-uti.patch.txt --]
[-- Type: text/plain, Size: 2415 bytes --]
From 5917e6602bd0e44c4a672bc4ac8c7a323b6300b6 Mon Sep 17 00:00:00 2001
From: Eugeniu Rosca <eugeniu.m.rosca@gmail.com>
Date: Sun, 24 Apr 2016 17:30:53 +0200
Subject: [PATCH v2] scripts/tags.sh: Handle missing {c,e,g}tags/cscope utilities
If the required ctags/etags/gtags/cscope host utility is not found,
current behavior is:
$> make cscope
GEN cscope
./scripts/tags.sh: line 140: cscope: command not found
$> make gtags
GEN gtags
./scripts/tags.sh: line 145: gtags: command not found
$> make tags
GEN tags
xargs: ctags: No such file or directory
sed: can't read tags: No such file or directory
Makefile:1509: recipe for target 'tags' failed
make: *** [tags] Error 2
$> make TAGS
GEN TAGS
xargs: etags: No such file or directory
sed: can't read TAGS: No such file or directory
Makefile:1509: recipe for target 'TAGS' failed
make: *** [TAGS] Error 2
Instead of implementing a more graceful handling, this patch only
makes sure that tags.sh script exits immediately upon the first
failure caused by the missing ctags/etags/gtags/cscope tool. By not
altering the exit code, the user will additionally get the failed
recipe in the root Makefile. The output becomes:
$> make cscope
GEN cscope
./scripts/tags.sh: line 140: cscope: command not found
Makefile:1517: recipe for target 'cscope' failed
make: *** [cscope] Error 127
$> make gtags
GEN gtags
./scripts/tags.sh: line 145: gtags: command not found
Makefile:1517: recipe for target 'gtags' failed
make: *** [gtags] Error 127
$> make tags
GEN tags
xargs: ctags: No such file or directory
Makefile:1517: recipe for target 'tags' failed
make: *** [tags] Error 127
$> make TAGS
GEN TAGS
xargs: etags: No such file or directory
Makefile:1517: recipe for target 'TAGS' failed
make: *** [TAGS] Error 127
Signed-off-by: Eugeniu Rosca <eugeniu.m.rosca@gmail.com>
---
scripts/tags.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/tags.sh b/scripts/tags.sh
index f72f48f..96b6dec 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -318,22 +318,22 @@ fi
remove_structs=
case "$1" in
"cscope")
- docscope
+ docscope || exit
;;
"gtags")
- dogtags
+ dogtags || exit
;;
"tags")
rm -f tags
- xtags ctags
+ xtags ctags || exit
remove_structs=y
;;
"TAGS")
rm -f TAGS
- xtags etags
+ xtags etags || exit
remove_structs=y
;;
esac
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-16 13:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-24 16:42 [PATCH] scripts/tags.sh: Exit gracefully if *tags tool not found Eugeniu Rosca
2016-04-25 12:35 ` Michal Marek
2016-05-15 13:44 ` Eugeniu Rosca
2016-05-16 7:06 ` Michal Marek
2016-05-16 13:37 ` [PATCH v2] scripts/tags.sh: Handle missing {c,e,g}tags/cscope utilities Eugeniu Rosca
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox