summaryrefslogtreecommitdiff
path: root/src/kash/var.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kash/var.c')
-rw-r--r--src/kash/var.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/src/kash/var.c b/src/kash/var.c
index cf73e8d..51e1001 100644
--- a/src/kash/var.c
+++ b/src/kash/var.c
@@ -68,11 +68,6 @@ extern APIRET
#endif
-#if defined(_MSC_VER) || defined(_WIN32)
- /* On Windows the PATH variable is called "Path". */
-# define PC_MIXED_PATH_VAR_NAME
-#endif
-
/*
@@ -363,6 +358,19 @@ setvareq(shinstance *psh, char *s, int flags)
struct var *vp, **vpp;
int nlen;
+#if defined(_MSC_VER) || defined(_WIN32)
+ /* On Windows PATH is often spelled 'Path', correct this here. */
+ if ( s[0] == 'P'
+ && s[1] == 'a'
+ && s[2] == 't'
+ && s[3] == 'h'
+ && (s[4] == '\0' || s[4] == '=') ) {
+ s[1] = 'A';
+ s[2] = 'T';
+ s[3] = 'H';
+ }
+#endif
+
if (aflag(psh))
flags |= VEXPORT;
vp = find_var(psh, s, &vpp, &nlen);
@@ -400,19 +408,6 @@ setvareq(shinstance *psh, char *s, int flags)
if (flags & VNOSET)
return;
-#ifdef PC_MIXED_PATH_VAR_NAME
- if ( nlen == 4
- && (s[0] == 'p' || s[0] == 'P')
- && (s[1] == 'a' || s[1] == 'A')
- && (s[2] == 't' || s[2] == 'T')
- && (s[3] == 'h' || s[3] == 'H') ) {
- s[0] = 'P';
- s[1] = 'A';
- s[2] = 'T';
- s[3] = 'H';
- }
-#endif
-
vp = ckmalloc(psh, sizeof (*vp));
vp->flags = flags & ~VNOFUNC;
vp->text = s;
@@ -927,22 +922,6 @@ find_var(shinstance *psh, const char *name, struct var ***vppp, int *lenp)
hashval = 2 * hashval + (unsigned char)*p++;
len = (int)(p - name);
-#ifdef PC_MIXED_PATH_VAR_NAME
- /* On Windows the PATH variable is called "Path". */
- if ( len == 4
- && (name[0] == 'p' || name[0] == 'P')
- && (name[1] == 'a' || name[1] == 'A')
- && (name[2] == 't' || name[2] == 'T')
- && (name[3] == 'h' || name[3] == 'H') )
- {
- name = "PATH";
- hashval = (unsigned char)'P';
- hashval = hashval * 2 + (unsigned char)'A';
- hashval = hashval * 2 + (unsigned char)'T';
- hashval = hashval * 2 + (unsigned char)'H';
- }
-#endif
-
if (lenp)
*lenp = len;
vpp = &psh->vartab[hashval % VTABSIZE];