DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] checkpatches: don't assume bash syntax
@ 2018-08-13 15:47 Stephen Hemminger
  2018-08-29  8:56 ` Hunt, David
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2018-08-13 15:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The read -d option is a bash extension and not avaiable in other
shells. On Debian, /bin/sh is dash and checktpatches would
fail with:
./devtools/checkpatches.sh: 52: read: Illegal option -d

Fix by using awk -e and adding necessary double backslash.

Fixes: 7413e7f2aeb3 ("devtools: alert on new calls to exit from libs")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/checkpatches.sh | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index ba795ad1dc36..c63162678538 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -49,7 +49,7 @@ check_forbidden_additions() {
     # - No search is done inside comments
     # - Both additions and removals of the expressions are checked
     #   A positive balance of additions fails the check
-	read -d '' awk_script << 'EOF'
+    awk -e '
 	BEGIN {
 		split(FOLDERS,deny_folders," ");
 		split(EXPRESSIONS,deny_expr," ");
@@ -70,7 +70,7 @@ check_forbidden_additions() {
 		# non comment code
 		if (in_comment == 0) {
 			for (i in deny_expr) {
-				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_added = "^\\+.*" deny_expr[i];
 				forbidden_removed="^-.*" deny_expr[i];
 				current = expressions[deny_expr[i]]
 				if ($0 ~ forbidden_added) {
@@ -90,13 +90,13 @@ check_forbidden_additions() {
 	}
 	# switch to next file , check if the balance of add/remove
 	# of previous filehad new additions
-	($0 ~ "^\+\+\+ b/") {
+	($0 ~ "^\\+\\+\\+ b/") {
 		in_file = 0;
 		if (count > 0) {
 			exit;
 		}
 		for (i in deny_folders) {
-			re = "^\+\+\+ b/" deny_folders[i];
+			re = "^\\+\\+\\+ b/" deny_folders[i];
 			if ($0 ~ deny_folders[i]) {
 				in_file = 1
 				last_file = $0
@@ -115,14 +115,8 @@ check_forbidden_additions() {
 			exit RET_ON_FAIL
 		}
 	}
-EOF
-	# ---------------------------------
-	# refrain from new additions of rte_panic() and rte_exit()
-	# multiple folders and expressions are separated by spaces
-	awk -v FOLDERS="lib drivers" \
-		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
-		-v RET_ON_FAIL=1 \
-		"$awk_script" -
+' -v FOLDERS="lib drivers" -v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+	-v RET_ON_FAIL=1 
 }
 
 number=0
-- 
2.18.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] checkpatches: don't assume bash syntax
  2018-08-13 15:47 [dpdk-dev] [PATCH] checkpatches: don't assume bash syntax Stephen Hemminger
@ 2018-08-29  8:56 ` Hunt, David
  0 siblings, 0 replies; 2+ messages in thread
From: Hunt, David @ 2018-08-29  8:56 UTC (permalink / raw)
  To: Stephen Hemminger, dev

Hi Stephen,


On 13/8/2018 4:47 PM, Stephen Hemminger wrote:
> The read -d option is a bash extension and not avaiable in other
> shells. On Debian, /bin/sh is dash and checktpatches would
> fail with:
> ./devtools/checkpatches.sh: 52: read: Illegal option -d
>
> Fix by using awk -e and adding necessary double backslash.
>
> Fixes: 7413e7f2aeb3 ("devtools: alert on new calls to exit from libs")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--snip--

The flavour of awk that's installed by default on Ubuntu is 'mawk' which 
does
not seem to have a '-e' option. However, for anyone tryung to run 
checkpatch
on Ubuntu with this patch, the quickest workaround is to install 'gawk',
which does have the -e option, then this patch works great.

Rgds,
Dave.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-29  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 15:47 [dpdk-dev] [PATCH] checkpatches: don't assume bash syntax Stephen Hemminger
2018-08-29  8:56 ` Hunt, David

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).