devtools: fix SPDX tag check
PATCH 1/1 devtools: fix SPDX tag check
If a file has no SPDX tag and is not filtered out by no_license_list, there will be an error when using its path containing a slash in the sed command delimited with slashes.
It is fixed by using the pipe character as sed command delimiter.
--- devtools/check-spdx-tag.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
devtools/check-spdx-tag.sh +1 -1
@@ -41,7 +41,7 @@ check_spdx() { files_without_spdx=$(cat $tmpfile) git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list > $tmpfile for file in $files_without_spdx ; do - sed -i "/^$file$/d" $tmpfile + sed -i "\|^$file$|d" $tmpfile done warnings=$(($warnings + $(wc -l < $tmpfile)))
Signature · 1 line
2.53.0
Quoted 4 lines · On Wed, 29 Apr 2026 15:09:35 +0200 Thomas Monjalon <[email protected]> wrote:
If a file has no SPDX tag and is not filtered out by
no_license_list, there will be an error when using its path containing a slash in the sed command delimited with slashes.
Quoted 8 lines
It is fixed by using the pipe character as sed command delimiter.
Fixes b99a3b8aa989 ("license: standardize SPDX tag")Reported-by David Marchand <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>---
Quoted 5 lines · Thomas Monjalon
If a file has no SPDX tag and is not filtered out by
no_license_list, there will be an error when using its path containing a slash in the sed command delimited with slashes.
Quoted 7 lines
It is fixed by using the pipe character as sed command delimiter.
Fixes b99a3b8aa989 ("license: standardize SPDX tag")Reported-by David Marchand <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
Signature · 1 line
David Marchand
Thomas Monjalon
AppliedQuoted 6 lines
Quoted 6 lines
If a file has no SPDX tag and is not filtered out by
no_license_list, there will be an error when using its path containing a slash in the sed command delimited with slashes.It is fixed by using the pipe character as sed command delimiter.
Quoted 7 lines
Quoted 5 lines
Fixes b99a3b8aa989 ("license: standardize SPDX tag")Reported-by David Marchand <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>Acked-by David Marchand <[email protected]>
Applied
Patch definitely improves the situation, but after a quick prompt Gemini suggested | grep -vF "$files_without_spdx" for safe filtering (man page confirms that patterns can be separated with newlines).
29/04/2026 18:17, Marat Khalili:
Quoted 1 line
Patch definitely improves the situation, but after a quick prompt Gemini suggested
| grep -vF "$files_without_spdx"for safe filtering (man page confirms that patterns can be separated with newlines).
Yes grep looks simpler than sed for this filter.
I'll send a v2 with your suggestion.
Thank you
PATCH v2 1/1 devtools: fix SPDX tag check
In reply to Thomas MonjalonIf a file has no SPDX tag and is not filtered out by no_license_list, there will be an error when using its path containing a slash in the sed command delimited with slashes.
It could be fixed by using another character as sed command delimiter. The chosen fix is to use grep instead of sed.
---
v1: replace / with |
v2: use grep instead of sed (Marat's suggestion)
--- devtools/check-spdx-tag.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
devtools/check-spdx-tag.sh +2 -4
@@ -39,10 +39,8 @@ check_spdx() { fi files_without_spdx=$(cat $tmpfile) - git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list > $tmpfile - for file in $files_without_spdx ; do - sed -i "/^$file$/d" $tmpfile - done + git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list | + grep -vF "$files_without_spdx" > $tmpfile warnings=$(($warnings + $(wc -l < $tmpfile))) $quiet || cat $tmpfile
Signature · 1 line
2.53.0
Quoted 18 lines
devtools/check-spdx-tag.sh +2
-5@@ -39,10 +39,8 @@ check_spdx() { fi files_without_spdx=$(cat $tmpfile) - git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list > $tmpfile - for file in $files_without_spdx ; do - sed -i "/^$file$/d" $tmpfile - done + git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list | + grep -vF "$files_without_spdx" > $tmpfile warnings=$(($warnings + $(wc -l < $tmpfile))) $quiet || cat $tmpfile --
Quoted 1 line
2.53.0
Sorry for forgetting to mention it right away, some kind of sentinel or if condition is needed if $files_without_spdx can be empty, don't know how realistic it is in practice and whether other parts are ready to handle this case. E.g. files_without_spdx=$(echo //sentinel; cat $tmpfile). I hope it won't make the whole thing too complicated and not worth it.
Otherwise,
30/04/2026 15:30, Marat Khalili:
Quoted 15 lines
Quoted 15 lines
devtools/check-spdx-tag.sh +2
-4@@ -39,10 +39,8 @@ check_spdx() { fi files_without_spdx=$(cat $tmpfile) - git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list > $tmpfile - for file in $files_without_spdx ; do - sed -i "/^$file$/d" $tmpfile - done + git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list | + grep -vF "$files_without_spdx" > $tmpfile
Quoted 10 lines
Quoted 4 lines
devtools/check-spdx-tag.sh +0
-1warnings=$(($warnings + $(wc -l < $tmpfile))) $quiet || cat $tmpfile --2.53.0
Sorry for forgetting to mention it right away, some kind of sentinel or if condition is needed if $files_without_spdx can be empty, don't know how realistic it is in practice and whether other parts are ready to handle this case. E.g.
files_without_spdx=$(echo //sentinel; cat $tmpfile). I hope it won't make the whole thing too complicated and not worth it.
Sorry I don't understand the need for a sentinel. The script is working fine with an empty files_without_spdx.
Quoted 2 lines
Sorry I don't understand the need for a sentinel. The script is working fine with an empty
files_without_spdx.
It may filter out everything instead of nothing in that case.
01/05/2026 11:55, Marat Khalili:
Quoted 4 lines
Quoted 2 lines
Sorry I don't understand the need for a sentinel. The script is working fine with an empty
files_without_spdx.It may filter out everything instead of nothing in that case.
OK you're right.
So it becomes complex.
The first solution with sed looks better.