Skip to contentSkip to conversation

devtools: fix symbol check for filename with space

PATCH Superseded Thomas Monjalon 2 participants 6 messages Jul 18, 2018 – Jul 20, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtools: fix symbol check for filename with space

If the patch filename or the temporary file path have a space in their name, the script check-symbol-change.sh does not work. The variables for the filenames must be enclosed in quotes in order to preserve spaces.

Fixes 4bec48184e33 ("devtools: add checks for ABI symbol addition")
---
 devtools/check-symbol-change.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
devtools/check-symbol-change.sh +9 -9
index 9952a8d66..69b874ace 100755
@@ -7,7 +7,7 @@ build_map_changes()
 	local fname=$1
 	local mapdb=$2
 
-	cat $fname | awk '
+	cat "$fname" | awk '
 		# Initialize our variables
 		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
 
@@ -71,10 +71,10 @@ build_map_changes()
 					print map " " sym " unknown del"
 				}
 			}
-		}' > ./$mapdb
+		}' > "$mapdb"
 
-		sort -u $mapdb > ./$mapdb.2
-		mv -f $mapdb.2 $mapdb
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
 
 }
 
@@ -111,7 +111,7 @@ check_for_rule_violations()
 				# to be moving from an already supported
 				# section or its a violation
 				grep -q \
-				"$mname $symname [^EXPERIMENTAL] del" $mapdb
+				"$mname $symname [^EXPERIMENTAL] del" "$mapdb"
 				if [ $? -ne 0 ]
 				then
 					echo -n "ERROR: symbol $symname "
@@ -133,7 +133,7 @@ check_for_rule_violations()
 				echo "gone through the deprecation process"
 			fi
 		fi
-	done < $mapdb
+	done < "$mapdb"
 
 	return $ret
 }
@@ -150,10 +150,10 @@ clean_and_exit_on_sig()
 	exit $exit_code
 }
 
-build_map_changes $patch $mapfile
-check_for_rule_violations $mapfile
+build_map_changes "$patch" "$mapfile"
+check_for_rule_violations "$mapfile"
 exit_code=$?
 
-rm -f $mapfile
+rm -f "$mapfile"
 
 exit $exit_code
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 devtools: fix symbol check for filename with space

If the patch filename or the temporary file path have a space in their name, the script check-symbol-change.sh does not work. The variables for the filenames must be enclosed in quotes in order to preserve spaces.

Fixes 4bec48184e33 ("devtools: add checks for ABI symbol addition")

---
v2: one occurence of "$mapfile" was missed in v1

---
 devtools/check-symbol-change.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
devtools/check-symbol-change.sh +10 -10
index 9952a8d66..40b72073a 100755
@@ -7,7 +7,7 @@ build_map_changes()
 	local fname=$1
 	local mapdb=$2
 
-	cat $fname | awk '
+	cat "$fname" | awk '
 		# Initialize our variables
 		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
 
@@ -71,10 +71,10 @@ build_map_changes()
 					print map " " sym " unknown del"
 				}
 			}
-		}' > ./$mapdb
+		}' > "$mapdb"
 
-		sort -u $mapdb > ./$mapdb.2
-		mv -f $mapdb.2 $mapdb
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
 
 }
 
@@ -111,7 +111,7 @@ check_for_rule_violations()
 				# to be moving from an already supported
 				# section or its a violation
 				grep -q \
-				"$mname $symname [^EXPERIMENTAL] del" $mapdb
+				"$mname $symname [^EXPERIMENTAL] del" "$mapdb"
 				if [ $? -ne 0 ]
 				then
 					echo -n "ERROR: symbol $symname "
@@ -133,7 +133,7 @@ check_for_rule_violations()
 				echo "gone through the deprecation process"
 			fi
 		fi
-	done < $mapdb
+	done < "$mapdb"
 
 	return $ret
 }
@@ -146,14 +146,14 @@ exit_code=1
 
 clean_and_exit_on_sig()
 {
-	rm -f $mapfile
+	rm -f "$mapfile"
 	exit $exit_code
 }
 
-build_map_changes $patch $mapfile
-check_for_rule_violations $mapfile
+build_map_changes "$patch" "$mapfile"
+check_for_rule_violations "$mapfile"
 exit_code=$?
 
-rm -f $mapfile
+rm -f "$mapfile"
 
 exit $exit_code
Signature · 1 line
2.17.1
#2 lore raw
Quoted 11 lines · Thomas Monjalon

If the patch filename or the temporary file path have a space in their name, the script check-symbol-change.sh does not work. The variables for the filenames must be enclosed in quotes in order to preserve spaces.

Fixes 4bec48184e33 ("devtools: add checks for ABI symbol addition")

---
v2: one occurence of "$mapfile" was missed in v1

I don't have any issue with this change, but the only way I see to introduce a space into the tempfile name is to set $TMPDIR to '/path/with silly spaces' or something simmilar. I think we discussed this before, but it would alsmot make sense to, instead of quoting everything, instead specify -p ./ to ensure the tempfile has no spaces.

Neil

Quoted 72 lines
---
 devtools/check-symbol-change.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
devtools/check-symbol-change.sh +10 -10
index 9952a8d66..40b72073a 100755
@@ -7,7 +7,7 @@ build_map_changes()
 	local fname=$1
 	local mapdb=$2
 
-	cat $fname | awk '
+	cat "$fname" | awk '
 		# Initialize our variables
 		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
 
@@ -71,10 +71,10 @@ build_map_changes()
 					print map " " sym " unknown del"
 				}
 			}
-		}' > ./$mapdb
+		}' > "$mapdb"
 
-		sort -u $mapdb > ./$mapdb.2
-		mv -f $mapdb.2 $mapdb
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
 
 }
 
@@ -111,7 +111,7 @@ check_for_rule_violations()
 				# to be moving from an already supported
 				# section or its a violation
 				grep -q \
-				"$mname $symname [^EXPERIMENTAL] del" $mapdb
+				"$mname $symname [^EXPERIMENTAL] del" "$mapdb"
 				if [ $? -ne 0 ]
 				then
 					echo -n "ERROR: symbol $symname "
@@ -133,7 +133,7 @@ check_for_rule_violations()
 				echo "gone through the deprecation process"
 			fi
 		fi
-	done < $mapdb
+	done < "$mapdb"
 
 	return $ret
 }
@@ -146,14 +146,14 @@ exit_code=1
 
 clean_and_exit_on_sig()
 {
-	rm -f $mapfile
+	rm -f "$mapfile"
 	exit $exit_code
 }
 
-build_map_changes $patch $mapfile
-check_for_rule_violations $mapfile
+build_map_changes "$patch" "$mapfile"
+check_for_rule_violations "$mapfile"
 exit_code=$?
 
-rm -f $mapfile
+rm -f "$mapfile"
 
 exit $exit_code
Signature · 1 line
2.17.1
#3 lore raw

19/07/2018 13:14, Neil Horman:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

If the patch filename or the temporary file path have a space in their name, the script check-symbol-change.sh does not work. The variables for the filenames must be enclosed in quotes in order to preserve spaces.

Fixes 4bec48184e33 ("devtools: add checks for ABI symbol addition")
Quoted 8 lines
Quoted 3 lines

---
v2: one occurence of "$mapfile" was missed in v1

I don't have any issue with this change, but the only way I see to introduce a space into the tempfile name is to set $TMPDIR to '/path/with silly spaces' or something simmilar. I think we discussed this before, but it would alsmot make sense to, instead of quoting everything, instead specify -p ./ to ensure the tempfile has no spaces.

When I save patches from my inbox, the filename has some spaces.

I think quoting variables is mandatory.

Acked-by
#4 lore raw
Quoted 19 lines · Thomas Monjalon

19/07/2018 13:14, Neil Horman:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

If the patch filename or the temporary file path have a space in their name, the script check-symbol-change.sh does not work. The variables for the filenames must be enclosed in quotes in order to preserve spaces.

Fixes 4bec48184e33 ("devtools: add checks for ABI symbol addition")
Quoted 8 lines
Quoted 3 lines

---
v2: one occurence of "$mapfile" was missed in v1

I don't have any issue with this change, but the only way I see to introduce a space into the tempfile name is to set $TMPDIR to '/path/with silly spaces' or something simmilar. I think we discussed this before, but it would alsmot make sense to, instead of quoting everything, instead specify -p ./ to ensure the tempfile has no spaces.

Quoted 7 lines

When I save patches from my inbox, the filename has some spaces.

I think quoting variables is mandatory.

Sure, it doesn't hurt anything really

author Applied
#5 lore raw

19/07/2018 17:37, Neil Horman:

Quoted 20 lines · Thomas Monjalon
Quoted 19 lines

19/07/2018 13:14, Neil Horman:

Quoted 17 lines · Thomas Monjalon
Quoted 11 lines

If the patch filename or the temporary file path have a space in their name, the script check-symbol-change.sh does not work. The variables for the filenames must be enclosed in quotes in order to preserve spaces.

Fixes 4bec48184e33 ("devtools: add checks for ABI symbol addition")

---
v2: one occurence of "$mapfile" was missed in v1

I don't have any issue with this change, but the only way I see to introduce a space into the tempfile name is to set $TMPDIR to '/path/with silly spaces' or something simmilar. I think we discussed this before, but it would alsmot make sense to, instead of quoting everything, instead specify -p ./ to ensure the tempfile has no spaces.

Quoted 8 lines
Quoted 5 lines

When I save patches from my inbox, the filename has some spaces.

I think quoting variables is mandatory.

Sure, it doesn't hurt anything really

Applied