aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-12-14 15:27:54 +0000
committerRon Yorston <rmy@pobox.com>2018-12-14 17:41:29 +0000
commita236242374daf911a01e998fabb1cc1268b2be7b (patch)
tree5e30a868b8580a645f94003e27bf96d6ebcd0ee1 /libbb
parent575581082befff0e049ef67fa36bbdd2ca737e29 (diff)
downloadbusybox-w32-a236242374daf911a01e998fabb1cc1268b2be7b.tar.gz
busybox-w32-a236242374daf911a01e998fabb1cc1268b2be7b.tar.bz2
busybox-w32-a236242374daf911a01e998fabb1cc1268b2be7b.zip
win32: special treatment for PATH
The PATH shell variable is a special case. It can be exported to the environment where it might be interpreted by native applications which assume the separator is ';'. Hence: - require that the separator used in PATH is ';' - enforce this by intercepting calls to setvareq() that set PATH and adjusting its value if necessary. As a result of this the code to parse PATH can be simplified by replacing the hardcoded Unix ':' path separator by the platform- dependent macro PATH_SEP. The MANPATH variable is also required to use ';' as its separator but since it's less likely to be used this isn't enforced.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/executable.c15
-rw-r--r--libbb/lineedit.c12
2 files changed, 6 insertions, 21 deletions
diff --git a/libbb/executable.c b/libbb/executable.c
index 835341ed9..87a40eeda 100644
--- a/libbb/executable.c
+++ b/libbb/executable.c
@@ -40,28 +40,21 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp)
40 */ 40 */
41 char *p, *n; 41 char *p, *n;
42#if ENABLE_PLATFORM_MINGW32 42#if ENABLE_PLATFORM_MINGW32
43 char sep, *w; 43 char *w;
44#endif 44#endif
45 45
46 p = *PATHp; 46 p = *PATHp;
47 while (p) { 47 while (p) {
48 int ex; 48 int ex;
49 49
50#if !ENABLE_PLATFORM_MINGW32 50 n = strchr(p, PATH_SEP);
51 n = strchr(p, ':');
52 if (n) *n = '\0'; 51 if (n) *n = '\0';
53#else
54 n = (char*)next_path_sep(p);
55 if (n) { sep = *n; *n = '\0'; }
56#endif
57 p = concat_path_file( 52 p = concat_path_file(
58 p[0] ? p : ".", /* handle "::" case */ 53 p[0] ? p : ".", /* handle "::" case */
59 filename 54 filename
60 ); 55 );
61#if !ENABLE_PLATFORM_MINGW32 56 if (n) *n++ = PATH_SEP;
62 if (n) *n++ = ':'; 57#if ENABLE_PLATFORM_MINGW32
63#else
64 if (n) *n++ = sep;
65 if ((w=alloc_win32_extension(p))) { 58 if ((w=alloc_win32_extension(p))) {
66 free(p); 59 free(p);
67 p = w; 60 p = w;
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 89178bbc3..6513219ce 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -798,11 +798,7 @@ static int path_parse(char ***p)
798 tmp = (char*)pth; 798 tmp = (char*)pth;
799 npth = 1; /* path component count */ 799 npth = 1; /* path component count */
800 while (1) { 800 while (1) {
801#if ENABLE_PLATFORM_MINGW32 801 tmp = strchr(tmp, PATH_SEP);
802 tmp = (char *)next_path_sep(tmp);
803#else
804 tmp = strchr(tmp, ':');
805#endif
806 if (!tmp) 802 if (!tmp)
807 break; 803 break;
808 tmp++; 804 tmp++;
@@ -815,11 +811,7 @@ static int path_parse(char ***p)
815 res[0] = tmp = xstrdup(pth); 811 res[0] = tmp = xstrdup(pth);
816 npth = 1; 812 npth = 1;
817 while (1) { 813 while (1) {
818#if ENABLE_PLATFORM_MINGW32 814 tmp = strchr(tmp, PATH_SEP);
819 tmp = (char *)next_path_sep(tmp);
820#else
821 tmp = strchr(tmp, ':');
822#endif
823 if (!tmp) 815 if (!tmp)
824 break; 816 break;
825 *tmp++ = '\0'; /* ':' -> '\0' */ 817 *tmp++ = '\0'; /* ':' -> '\0' */