kbuild: replace BASH-specific ${@:2} with shift and ${@}
Subsystems (4)
PATCH 1/1 kbuild: replace BASH-specific ${@:2} with shift and ${@}
${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on BASH. Use shift and ${@} instead to fix this issue.
--- scripts/link-vmlinux.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
scripts/link-vmlinux.sh +11 -5
@@ -57,12 +57,16 @@ modpost_link() # Link of vmlinux # ${1} - output file -# ${@:2} - optional extra .o files +# ${2}, ${3}, ... - optional extra .o files vmlinux_link() { local lds="${objtree}/${KBUILD_LDS}" + local output=${1} local objects + # skip output file argument + shift + if [ "${SRCARCH}" != "um" ]; then objects="--whole-archive \ ${KBUILD_VMLINUX_OBJS} \
@@ -70,9 +74,10 @@ vmlinux_link() --start-group \ ${KBUILD_VMLINUX_LIBS} \ --end-group \ - ${@:2}" + ${@}" - ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} -o ${1} \ + ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ + -o ${output} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \
@@ -81,9 +86,10 @@ vmlinux_link() -Wl,--start-group \ ${KBUILD_VMLINUX_LIBS} \ -Wl,--end-group \ - ${@:2}" + ${@}" - ${CC} ${CFLAGS_vmlinux} -o ${1} \ + ${CC} ${CFLAGS_vmlinux} \ + -o ${output} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread
Signature · 1 line
2.21.0
Quoted 8 lines · Andrii Nakryiko
${@:2} is BASH-specific extension, which makes
link-vmlinux.shrely on BASH. Use shift and ${@} instead to fix this issue.Reported-by Stephen Rothwell <[email protected]>Fixes 341dfcf8d78e ("btf: expose BTF info through sysfs")Cc Stephen Rothwell <[email protected]>Cc Masahiro Yamada <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Tested with bash/sh/csh, all works.
Quoted 53 lines
--- scripts/link-vmlinux.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)scripts/link-vmlinux.sh +11
-5@@ -57,12 +57,16 @@ modpost_link() # Link of vmlinux # ${1} - output file -# ${@:2} - optional extra .o files +# ${2}, ${3}, ... - optional extra .o files vmlinux_link() { local lds="${objtree}/${KBUILD_LDS}" + local output=${1} local objects + # skip output file argument + shift + if [ "${SRCARCH}" != "um" ]; then objects="--whole-archive \ ${KBUILD_VMLINUX_OBJS} \@@ -70,9 +74,10 @@ vmlinux_link() --start-group \ ${KBUILD_VMLINUX_LIBS} \ --end-group \ - ${@:2}" + ${@}" - ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} -o ${1} \ + ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ + -o ${output} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \@@ -81,9 +86,10 @@ vmlinux_link() -Wl,--start-group \ ${KBUILD_VMLINUX_LIBS} \ -Wl,--end-group \ - ${@:2}" + ${@}" - ${CC} ${CFLAGS_vmlinux} -o ${1} \ + ${CC} ${CFLAGS_vmlinux} \ + -o ${output} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread
Quoted 6 lines · Yonghong Song
Quoted 3 lines · Andrii Nakryiko
${@:2} is BASH-specific extension, which makes
link-vmlinux.shrely on BASH. Use shift and ${@} instead to fix this issue.
Quoted 7 lines
Quoted 5 lines
Reported-by Stephen Rothwell <[email protected]>Fixes 341dfcf8d78e ("btf: expose BTF info through sysfs")Cc Stephen Rothwell <[email protected]>Cc Masahiro Yamada <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>Tested with bash/sh/csh, all works.
Thanks for testing, Yonghong! In my system sh is an alias to bash, so it still behaved like bash and didn't fail even with existing code. I didn't have an opportunity to install csh at that time and try it, so thanks a lot for confirming. I basically relied on documentation to verify shift and $@ is not BASH'ism.
Quoted 55 lines
Acked-by Yonghong Song <[email protected]>Quoted 53 lines
--- scripts/link-vmlinux.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)scripts/link-vmlinux.sh +11
-5@@ -57,12 +57,16 @@ modpost_link() # Link of vmlinux # ${1} - output file -# ${@:2} - optional extra .o files +# ${2}, ${3}, ... - optional extra .o files vmlinux_link() { local lds="${objtree}/${KBUILD_LDS}" + local output=${1} local objects + # skip output file argument + shift + if [ "${SRCARCH}" != "um" ]; then objects="--whole-archive \ ${KBUILD_VMLINUX_OBJS} \@@ -70,9 +74,10 @@ vmlinux_link() --start-group \ ${KBUILD_VMLINUX_LIBS} \ --end-group \ - ${@:2}" + ${@}" - ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} -o ${1} \ + ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ + -o ${output} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \@@ -81,9 +86,10 @@ vmlinux_link() -Wl,--start-group \ ${KBUILD_VMLINUX_LIBS} \ -Wl,--end-group \ - ${@:2}" + ${@}" - ${CC} ${CFLAGS_vmlinux} -o ${1} \ + ${CC} ${CFLAGS_vmlinux} \ + -o ${output} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread
Quoted 13 lines
-----Original Message-----
From: Andrii Nakryiko <[email protected]>
Sent: Friday, September 06, 2019 3:00 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Andrii Nakryiko <[email protected]>; Stephen Rothwell <[email protected]>; Yamada, Masahiro/山田 真弘 <[email protected]>
Subject: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}
Quoted 8 lines
${@:2} is BASH-specific extension, which makes
link-vmlinux.shrely on BASH. Use shift and ${@} instead to fix this issue.Reported-by Stephen Rothwell <[email protected]>Fixes 341dfcf8d78e ("btf: expose BTF info through sysfs")Cc Stephen Rothwell <[email protected]>Cc Masahiro Yamada <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Alexei Starovoitov
AppliedQuoted 17 lines · On Fri, Sep 6, 2019 at 3:34 AM <[email protected]> wrote:
Quoted 17 lines
-----Original Message-----
From: Andrii Nakryiko <[email protected]>
Sent: Friday, September 06, 2019 3:00 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Andrii Nakryiko <[email protected]>; Stephen Rothwell <[email protected]>; Yamada, Masahiro/山田 真弘 <[email protected]>
Subject: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}${@:2} is BASH-specific extension, which makes
link-vmlinux.shrely on BASH. Use shift and ${@} instead to fix this issue.
Quoted 7 lines
Quoted 5 lines
Reported-by Stephen Rothwell <[email protected]>Fixes 341dfcf8d78e ("btf: expose BTF info through sysfs")Cc Stephen Rothwell <[email protected]>Cc Masahiro Yamada <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>Reviewed-by Masahiro Yamada <[email protected]>
Applied. Thanks