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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxx>
> ---
>  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



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux