From 2af141a2c069c56d56f110414f600f3a38ad8617 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 30 Aug 2023 13:07:13 +0100 Subject: ash: changes to login shell functionality Upstream BusyBox supports the usual Unix functionality where the login process adds a '-' prefix to the shell's argv[0]. Since busybox-w32 doesn't have a login process this serves no purpose and can be removed. Instead it would be useful to have a way to invoke a login shell without requiring any arguments. Advantages would be: - easier to configure busybox-w32 'ash' as the SSH login shell; - double clicking on a shell binary could start a login shell. Add 'lash' as an alias for 'ash' which starts a login shell without requiring the '-l' option. Saves 16 bytes. --- libbb/appletlib.c | 3 ++- shell/ash.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index bf9ae4603..6b610743a 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -1379,9 +1379,10 @@ int main(int argc UNUSED_PARAM, char **argv) argv++; # endif applet_name = argv[0]; +# if !ENABLE_PLATFORM_MINGW32 if (applet_name[0] == '-') applet_name++; -# if ENABLE_PLATFORM_MINGW32 +# else str_tolower(argv[0]); bs_to_slash(argv[0]); if (has_exe_suffix_or_dot(argv[0])) { diff --git a/shell/ash.c b/shell/ash.c index 2ea87a049..95f399b0b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -209,6 +209,9 @@ //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) // APPLET_ODDNAME:name main location suid_type help //applet:IF_SH_IS_ASH( APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) +//applet:IF_PLATFORM_MINGW32( +//applet:IF_SH_IS_ASH( APPLET_ODDNAME(lash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) +//applet:) //applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) //kbuild:lib-$(CONFIG_SHELL_ASH) += ash.o ash_ptr_hack.o shell_common.o @@ -15999,7 +16002,11 @@ procargs(char **argv) int login_sh; xargv = argv; +#if ENABLE_PLATFORM_MINGW32 + login_sh = applet_name[0] == 'l'; +#else login_sh = xargv[0] && xargv[0][0] == '-'; +#endif #if NUM_SCRIPTS > 0 if (minusc) goto setarg0; -- cgit v1.2.3-55-g6feb