Skip to contentSkip to conversation

fs/cpio/init: preserve arguments

PATCH New Gaël PORTAY 4 participants 6 messages Feb 21, 2018 – Feb 26, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/cpio/init: preserve arguments

Use "$@" instead of $* to preserve argument.

---
 fs/cpio/init | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cpio/init +1 -1
index a275482177..dbe09ac68e 100755
@@ -4,4 +4,4 @@
 exec 0</dev/console
 exec 1>/dev/console
 exec 2>/dev/console
-exec /sbin/init $*
+exec /sbin/init "$@"
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/1 fs/cpio/init: preserve arguments

Hello,

Quoted 1 line · Ga?l PORTAY

Use "$@" instead of $* to preserve argument.

Thanks for your patch, but why ? The commit log needs to explain the use-case/motivations/reasons.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#2 lore raw

PATCH 1/1 fs/cpio/init: preserve arguments

Quoted 7 lines · Thomas Petazzoni

Hello,

Quoted 1 line · Ga?l PORTAY

Use "$@" instead of $* to preserve argument.

Thanks for your patch, but why ? The commit log needs to explain the use-case/motivations/reasons.

Using $* here will split each of the arguments at the spaces (well, at any of the characters fro $IFS): that means that passing 'has space' as argument, using $* will result in two arguments 'has' and 'space' being passed down. Using "$@" prevents $IFS-splitting and passes argument unchanged as-is.

In most cases whenever there is a $* in a shell script, pretty much it means that passing the parameters with spaces (file names, paths, etc.) will break things.

Cheers,

--
Adri?n ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180221/3604ce5f/attachment.asc>

#3 lore raw

PATCH 1/1 fs/cpio/init: preserve arguments

In reply to Thomas Petazzoni

Thomas,

Quoted 7 lines · Thomas Petazzoni

Hello,

Quoted 1 line · Ga?l PORTAY

Use "$@" instead of $* to preserve argument.

Thanks for your patch, but why ? The commit log needs to explain the use-case/motivations/reasons.

Sorry for this lack of information.

I will send a v2 with an appropriate commit message.

Quoted 8 lines

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com

Regards,
Gael

#4 lore raw

PATCH 1/1 fs/cpio/init: preserve arguments

In reply to Gaël PORTAY
Quoted 3 lines · Ga?l PORTAY

Use "$@" instead of $* to preserve argument.

Quoted 21 lines
---
 fs/cpio/init | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cpio/init +1 -1
index a275482177..dbe09ac68e 100755
@@ -4,4 +4,4 @@
 exec 0</dev/console
 exec 1>/dev/console
 exec 2>/dev/console
-exec /sbin/init $*
+exec /sbin/init "$@"
Signature · 6 lines
2.16.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180221/538c786a/attachment.asc>