diff mbox series

[02/20] kbuild: scripts/install.sh: properly quote all variables

Message ID 20210407053419.449796-3-gregkh@linuxfoundation.org (mailing list archive)
State New, archived
Headers show
Series kbuild: unify the install.sh script usage | expand

Commit Message

Greg KH April 7, 2021, 5:34 a.m. UTC
A few variables are quoted to handle spaces in directory names, but not
all of them.  Properly quote everything so that the kernel build can
handle working correctly with directory names with spaces.

This change makes the script "shellcheck" clean now.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 scripts/install.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Masahiro Yamada April 7, 2021, 10:59 a.m. UTC | #1
On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> A few variables are quoted to handle spaces in directory names, but not
> all of them.  Properly quote everything so that the kernel build can
> handle working correctly with directory names with spaces.
>
> This change makes the script "shellcheck" clean now.
>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  scripts/install.sh | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/install.sh b/scripts/install.sh
> index d13ec1c38640..c183d6ddd00c 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -33,21 +33,21 @@ verify "$3"
>
>  # User may have a custom install script
>
> -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
> -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
> +if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec ~/bin/"${INSTALLKERNEL}" "$@"; fi
> +if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; fi
>
>  # Default install - same as make zlilo
>
> -if [ -f $4/vmlinuz ]; then
> -       mv $4/vmlinuz $4/vmlinuz.old
> +if [ -f "$4"/vmlinuz ]; then
> +       mv "$4"/vmlinuz "$4"/vmlinuz.old
>  fi


Another way of quoting is doing like this:

  if [ -f "$4/vmlinuz" ]; then
       mv "$4/vmlinuz" "$4/vmlinuz.old"
  fi


shellcheck is still satisfied.





Because you will add more quotes,
quoting the whole of each parameter might be cleaner.

See my comment in 07/20.








> -if [ -f $4/System.map ]; then
> -       mv $4/System.map $4/System.old
> +if [ -f "$4"/System.map ]; then
> +       mv "$4"/System.map "$4"/System.old
>  fi
>
> -cat $2 > $4/vmlinuz
> -cp $3 $4/System.map
> +cat "$2" > "$4"/vmlinuz
> +cp "$3" "$4"/System.map
>
>  if [ -x /sbin/lilo ]; then
>         /sbin/lilo
> --
> 2.31.1
>


--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/install.sh b/scripts/install.sh
index d13ec1c38640..c183d6ddd00c 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -33,21 +33,21 @@  verify "$3"
 
 # User may have a custom install script
 
-if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
-if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
+if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec ~/bin/"${INSTALLKERNEL}" "$@"; fi
+if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; fi
 
 # Default install - same as make zlilo
 
-if [ -f $4/vmlinuz ]; then
-	mv $4/vmlinuz $4/vmlinuz.old
+if [ -f "$4"/vmlinuz ]; then
+	mv "$4"/vmlinuz "$4"/vmlinuz.old
 fi
 
-if [ -f $4/System.map ]; then
-	mv $4/System.map $4/System.old
+if [ -f "$4"/System.map ]; then
+	mv "$4"/System.map "$4"/System.old
 fi
 
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
+cat "$2" > "$4"/vmlinuz
+cp "$3" "$4"/System.map
 
 if [ -x /sbin/lilo ]; then
        /sbin/lilo