From 67285965f3d2c266ee37fec17d339b717752f8b0 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Wed, 14 Jan 2004 09:34:51 +0000 Subject: Vodz last_patch_122, Check $PATH at runtime to fix tab completion --- shell/ash.c | 3 +++ shell/cmdedit.c | 14 +++++++++++--- shell/cmdedit.h | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index b34f0583f..80145dae5 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4117,6 +4117,9 @@ changepath(const char *newval) firstchange = 0; clearcmdentry(firstchange); builtinloc = idx_bltin; +#ifdef CONFIG_FEATURE_COMMAND_EDITING + cmdedit_path_lookup = newval; +#endif } diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 884489b45..ec861df54 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c @@ -43,6 +43,8 @@ #include "busybox.h" +#include "../shell/cmdedit.h" + #ifdef CONFIG_LOCALE_SUPPORT #define Isprint(c) isprint((c)) #else @@ -609,14 +611,20 @@ enum { FIND_FILE_ONLY = 2, }; +#ifdef CONFIG_ASH +const char *cmdedit_path_lookup; +#else +#define cmdedit_path_lookup getenv("PATH") +#endif + static int path_parse(char ***p, int flags) { int npth; - char *tmp; - char *pth; + const char *tmp; + const char *pth; /* if not setenv PATH variable, to search cur dir "." */ - if (flags != FIND_EXE_ONLY || (pth = getenv("PATH")) == 0 || + if (flags != FIND_EXE_ONLY || (pth = cmdedit_path_lookup) == 0 || /* PATH= or PATH=: */ *pth == 0 || (*pth == ':' && *(pth + 1) == 0)) { return 1; diff --git a/shell/cmdedit.h b/shell/cmdedit.h index 991dafcd1..4c0c09d76 100644 --- a/shell/cmdedit.h +++ b/shell/cmdedit.h @@ -3,6 +3,10 @@ int cmdedit_read_input(char* promptStr, char* command); +#ifdef CONFIG_ASH +extern const char *cmdedit_path_lookup; +#endif + #ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY void load_history ( const char *fromfile ); void save_history ( const char *tofile ); -- cgit v1.2.3