aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-08-28 09:47:51 +0100
committerRon Yorston <rmy@pobox.com>2023-08-28 09:47:51 +0100
commit52922a1509d4623b7efdc8e7091be514cf4cd261 (patch)
tree58b80f5cd553bfcdd159af6d56ee685ca300c06c
parent8abbf4599d4ea84f084a7ce2832b59a793607699 (diff)
downloadbusybox-w32-52922a1509d4623b7efdc8e7091be514cf4cd261.tar.gz
busybox-w32-52922a1509d4623b7efdc8e7091be514cf4cd261.tar.bz2
busybox-w32-52922a1509d4623b7efdc8e7091be514cf4cd261.zip
libbb: fix #!/bin/busybox
Commit 3476fb9f4c (ps: display interpreted script name in comm column) required the applet start up code to detect the index of the script in a shebang command line. When a script starts with '#!/bin/busybox' the argument list is shifted in busybox_main() but the script index wasn't adjusted to match. This caused the command to fail. Make the proper adjustment. Add 16 bytes. (GitHub issue #357)
-rw-r--r--libbb/appletlib.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 8801c732d..bf9ae4603 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -1113,6 +1113,10 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
1113 /* We support "busybox /a/path/to/applet args..." too. Allows for 1113 /* We support "busybox /a/path/to/applet args..." too. Allows for
1114 * "#!/bin/busybox"-style wrappers 1114 * "#!/bin/busybox"-style wrappers
1115 */ 1115 */
1116# if ENABLE_PLATFORM_MINGW32
1117 if (interp)
1118 --interp;
1119# endif
1116 applet_name = bb_get_last_path_component_nostrip(argv[0]); 1120 applet_name = bb_get_last_path_component_nostrip(argv[0]);
1117 } 1121 }
1118 run_applet_and_exit(applet_name, argv); 1122 run_applet_and_exit(applet_name, argv);