Skip to contentSkip to conversation

powerpc/tools: Don't quote $objdump in scripts

PATCH Applied Michael Ellerman 4 participants 6 messages Oct 24, 2019 – Nov 7, 2019 PowerPC

lore
Share & tools
lore

Michael Ellerman

author reviewer
#0 lore raw

PATCH 1/1 powerpc/tools: Don't quote $objdump in scripts

Some of our scripts are passed $objdump and then call it as "$objdump". This doesn't work if it contains spaces because we're using ccache, for example you get errors such as:

./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory

Fix it by not quoting the string when we expand it, allowing the shell to do the right thing for us.

Fixes a71aa05e1416 ("powerpc: Convert relocs_check to a shell script using grep")
Fixes 4ea80652dc75 ("powerpc/64s: Tool to flag direct branches from unrelocated interrupt vectors")
---
 arch/powerpc/tools/relocs_check.sh       | 2 +-
 arch/powerpc/tools/unrel_branch_check.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/tools/relocs_check.sh +1 -1
index 2b4e959caa36..7b9fe0a567cf 100755
@@ -20,7 +20,7 @@ objdump="$1"
 vmlinux="$2"
 
 bad_relocs=$(
-"$objdump" -R "$vmlinux" |
+$objdump -R "$vmlinux" |
 	# Only look at relocation lines.
 	grep -E '\<R_' |
 	# These relocations are okay
arch/powerpc/tools/unrel_branch_check.sh +2 -2
index 1e972df3107e..77114755dc6f 100755
@@ -18,14 +18,14 @@ vmlinux="$2"
 #__end_interrupts should be located within the first 64K
 
 end_intr=0x$(
-"$objdump" -R "$vmlinux" -d --start-address=0xc000000000000000		\
+$objdump -R "$vmlinux" -d --start-address=0xc000000000000000           \
 		 --stop-address=0xc000000000010000 |
 grep '\<__end_interrupts>:' |
 awk '{print $1}'
 )
 
 BRANCHES=$(
-"$objdump" -R "$vmlinux" -D --start-address=0xc000000000000000		\
+$objdump -R "$vmlinux" -D --start-address=0xc000000000000000           \
 		--stop-address=${end_intr} |
 grep -e "^c[0-9a-f]*:[[:space:]]*\([0-9a-f][0-9a-f][[:space:]]\)\{4\}[[:space:]]*b" |
 grep -v '\<__start_initialization_multiplatform>' |
Signature · 1 line
2.21.0
#1 lore raw
Quoted 9 lines · Michael Ellerman

Some of our scripts are passed $objdump and then call it as "$objdump". This doesn't work if it contains spaces because we're using ccache, for example you get errors such as:

./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory

Fix it by not quoting the string when we expand it, allowing the shell to do the right thing for us.

This breaks things for people with spaces in their paths. Why doesn't your user use something like alias objdump="ccache ppc64le-objdump" , instead?

Segher

#2 lore raw

From: Segher Boessenkool

Quoted 6 lines

Sent: 24 October 2019 18:29

Quoted 4 lines · Michael Ellerman

Some of our scripts are passed $objdump and then call it as "$objdump". This doesn't work if it contains spaces because we're using ccache, for example you get errors such as:

Quoted 8 lines
Quoted 5 lines

./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory

Fix it by not quoting the string when we expand it, allowing the shell to do the right thing for us.

This breaks things for people with spaces in their paths. Why doesn't your user use something like alias objdump="ccache ppc64le-objdump" , instead?

Given that make doesn't handle spaces in filenames it is likely that a build will have terrible issues is there are spaces in any directory names. (It is a right PITA running make on a certain OS.)
For command paths, spaces can be replaced by ? relying on shell globbing to restore the space.

OTOH rather than alias, put the name of a script containing:
#! /bin/sh
exec ccache ppc64le-objdump "$@"
into $objdump.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

author reviewer
#3 lore raw
In reply to Segher Boessenkool
Quoted 5 lines · Segher Boessenkool
Quoted 4 lines · Michael Ellerman

Some of our scripts are passed $objdump and then call it as "$objdump". This doesn't work if it contains spaces because we're using ccache, for example you get errors such as:

Quoted 7 lines
Quoted 5 lines

./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory

Fix it by not quoting the string when we expand it, allowing the shell to do the right thing for us.

This breaks things for people with spaces in their paths.

Spaces in their what? Who does that? :)

Also we don't support it:

  $ pwd
  $ /home/michael/foo bar
  $ make clean
  Makefile:147: *** source directory cannot contain spaces or colons.  Stop.

cheers

#4 lore raw
Quoted 9 lines · Michael Ellerman
Quoted 8 lines · Segher Boessenkool
Quoted 7 lines · Michael Ellerman

Some of our scripts are passed $objdump and then call it as "$objdump". This doesn't work if it contains spaces because we're using ccache, for example you get errors such as:

./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Fix it by not quoting the string when we expand it, allowing the shell to do the right thing for us.

This breaks things for people with spaces in their paths.

Spaces in their what? Who does that? :)

I know, right?

Quoted 6 lines

Also we don't support it:

  $ pwd
  $ /home/michael/foo bar
  $ make clean
  Makefile:147: *** source directory cannot contain spaces or colons.  Stop.

Of course. But it's shell scripting 101 that you *do* quote all variable expansions. Do you want to set a bad example? ;-)

Segher

#5 lore raw
In reply to Michael Ellerman
Quoted 7 lines · Michael Ellerman

Some of our scripts are passed $objdump and then call it as "$objdump". This doesn't work if it contains spaces because we're using ccache, for example you get errors such as:

./arch/powerpc/tools/relocs_check.sh: line 48: ccache ppc64le-objdump: No such file or directory ./arch/powerpc/tools/unrel_branch_check.sh: line 26: ccache ppc64le-objdump: No such file or directory

Quoted 6 lines

Fix it by not quoting the string when we expand it, allowing the shell to do the right thing for us.

Fixes a71aa05e1416 ("powerpc: Convert relocs_check to a shell script using grep")
Fixes 4ea80652dc75 ("powerpc/64s: Tool to flag direct branches from unrelocated interrupt vectors")

Applied to powerpc next.

https://git.kernel.org/powerpc/c/e44ff9ea8f4c8a90c82f7b85bd4f5e497c841960

cheers