OSDN Git Service

scripts/tags.sh: fix direct execution of scripts/tags.sh
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 29 Apr 2019 04:06:43 +0000 (13:06 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 3 May 2019 14:05:01 +0000 (23:05 +0900)
I thought this script was run via "make tags" etc. but some people
run it directly.

Prior to commit a9a49c2ad9b9 ("kbuild: use $(srctree) instead of
KBUILD_SRC to check out-of-tree build"), in such a usecase, "tree"
was set empty since KBUILD_SRC is undefined. Now, "tree" is set to
"${srctree}/", which is evaluated to "/".

Fix it by taking into account the case where "srctree" is unset.

Link: https://lkml.org/lkml/2019/4/19/501
Fixes: a9a49c2ad9b9 ("kbuild: use $(srctree) instead of KBUILD_SRC to check out-of-tree build")
Reported-by: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/tags.sh

index 6a55180..70e14c6 100755 (executable)
@@ -19,7 +19,7 @@ ignore="$ignore ( -name *.mod.c ) -prune -o"
 # Do not use full path if we do not use O=.. builds
 # Use make O=. {tags|cscope}
 # to force full paths for a non-O= build
-if [ "${srctree}" = "." ]; then
+if [ "${srctree}" = "." -o -z "${srctree}" ]; then
        tree=
 else
        tree=${srctree}/