From 2cf6277bbbc925f2c6267f5fb10d6c325dc0b1dd Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 10 May 2022 15:12:52 +0100 Subject: win32: make default PATH more likely to work The default PATH defined as BB_PATH_ROOT_PATH is used: - to set PATH in the shell if the environment variable doesn't exist; - as the default in 'which' if there's no PATH env var; - when the option 'command -p' is given. Replace the Unix-centric default with something more likely to work on Microsoft Windows. No guarantees, though. (GitHub issue #253) --- include/libbb.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 6d6fc28f0..6e4e7583f 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -2354,10 +2354,19 @@ extern const char bb_busybox_exec_path[] ALIGN1; #endif #if !ENABLE_PLATFORM_MINGW32 #define BB_PATH_ROOT_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH +extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ +#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) +/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, + * but I want to save a few bytes here: + */ +#define bb_default_path (bb_PATH_root_path + sizeof("PATH=/sbin:/usr/sbin")) #define PATH_SEP ':' #define PATH_SEP_STR ":" #else -#define BB_PATH_ROOT_PATH "PATH=/sbin;/usr/sbin;/bin;/usr/bin" BB_ADDITIONAL_PATH +#define BB_PATH_ROOT_PATH "PATH=C:/Windows/System32;C:/Windows" BB_ADDITIONAL_PATH +extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ +#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) +#define bb_default_path (bb_PATH_root_path + sizeof("PATH")) #define PATH_SEP ';' #define PATH_SEP_STR ";" extern const char bbvar[] ALIGN1; @@ -2366,12 +2375,6 @@ extern const char bbvar[] ALIGN1; #define BB_SKIP_ANSI_EMULATION bbafter(BB_OVERRIDE_APPLETS) #define BB_SYSTEMROOT bbafter(BB_SKIP_ANSI_EMULATION) #endif -extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ -#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) -/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, - * but I want to save a few bytes here: - */ -#define bb_default_path (bb_PATH_root_path + sizeof("PATH=/sbin:/usr/sbin")) extern const int const_int_0; //extern const int const_int_1; -- cgit v1.2.3-55-g6feb