Skip to contentSkip to conversation

scripts/tags.sh: use more portable -path instead of -wholename

PATCH New Wei Yang 1 participant 4 messages Dec 29, 2023

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/4 scripts/tags.sh: use more portable -path instead of -wholename

According to the manual, -path is more portable than -wholename. Also for consistency, let's use -path here.

CC Guennadi Liakhovetski <[email protected]>
CC WANG Cong <[email protected]>
CC Michal Marek <[email protected]>

merg

---
 scripts/tags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tags.sh +1 -1
index a70d43723146..fbae1a087ee1 100755
@@ -50,7 +50,7 @@ fi
 find_arch_sources()
 {
 	for i in $archincludedir; do
-		prune="$prune -wholename $i -prune -o"
+		prune="$prune ( -path $i ) -prune -o"
 	done
 	find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print;
 }
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/4 scripts/tags.sh: add local annotation

Commit 'f81b1be40c44 tags: include headers before source files' introduce two local variables.

Let's add local annotation to make it obvious.

---
 scripts/tags.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/tags.sh +2 -2
index fbae1a087ee1..83e3731b5bdf 100755
@@ -50,7 +50,7 @@ fi
 find_arch_sources()
 {
 	for i in $archincludedir; do
-		prune="$prune ( -path $i ) -prune -o"
+		local prune="$prune ( -path $i ) -prune -o"
 	done
 	find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print;
 }
@@ -58,7 +58,7 @@ find_arch_sources()
 # find sources in arch/$1/include
 find_arch_include_sources()
 {
-	include=$(find ${tree}arch/$1/ -name include -type d -print);
+	local include=$(find ${tree}arch/$1/ -name include -type d -print);
 	if [ -n "$include" ]; then
 		archincludedir="$archincludedir $include"
 		find $include $ignore -name "$2" -not -type l -print;
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 3/4 scripts/tags.sh: use -n to test archinclude

In reply to Wei Yang

In bash, "! -z" is equivalent to "-n", which seems to be more intuitive.

CC Sam Ravnborg <[email protected]>
---
 scripts/tags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tags.sh +1 -1
index 83e3731b5bdf..5061ec255291 100755
@@ -89,7 +89,7 @@ find_sources()
 all_sources()
 {
 	find_arch_include_sources ${SRCARCH} '*.[chS]'
-	if [ ! -z "$archinclude" ]; then
+	if [ -n "$archinclude" ]; then
 		find_arch_include_sources $archinclude '*.[chS]'
 	fi
 	find_include_sources '*.[chS]'
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH 4/4 scripts/tags.sh: remove find_sources

In reply to Wei Yang

After commit '4f628248a578 kbuild: reintroduce ALLSOURCE_ARCHS support for tags/cscope', find_sources only invoke find_arch_sources.

---
 scripts/tags.sh | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
scripts/tags.sh +2 -7
index 5061ec255291..45568fee0cbb 100755
@@ -81,11 +81,6 @@ find_other_sources()
 	       -name "$1" -not -type l -print;
 }
 
-find_sources()
-{
-	find_arch_sources $1 "$2"
-}
-
 all_sources()
 {
 	find_arch_include_sources ${SRCARCH} '*.[chS]'
@@ -95,7 +90,7 @@ all_sources()
 	find_include_sources '*.[chS]'
 	for arch in $ALLSOURCE_ARCHS
 	do
-		find_sources $arch '*.[chS]'
+		find_arch_sources $arch '*.[chS]'
 	done
 	find_other_sources '*.[chS]'
 }
@@ -125,7 +120,7 @@ all_kconfigs()
 	find ${tree}arch/ -maxdepth 1 $ignore \
 	       -name "Kconfig*" -not -type l -print;
 	for arch in $ALLSOURCE_ARCHS; do
-		find_sources $arch 'Kconfig*'
+		find_arch_sources $arch 'Kconfig*'
 	done
 	find_other_sources 'Kconfig*'
 }
Signature · 1 line
2.34.1