From 8e139871fe0c79631e0bd6024a8d515408a93da1 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 4 Jul 2002 00:19:46 +0000 Subject: Patch from Stewart Brodie to fix ash: When alias support is not configured, ash believes that command parameters that look like dd's "if=/dev/zero" are requests to set a temporary environment variable whilst dd is running, even though it appears after the command name. This is caused by the re-use of the checkalias global variable to indicate when both alias checking and environment variable checking. The failure to reset this flag is due to the reset action being performed only inside the feature check CHECK_ASH_ALIAS. Hence ash works as expected when aliases are configured in, and fails when not. Example script using 'date' with different settings of TZ: # TZ=Europe/London # export TZ # date Thu May 30 17:18:49 BST 2002 # TZ=America/New_York date Thu May 30 12:19:10 EDT 2002 # date Thu May 30 17:19:12 BST 2002 # date TZ=America/New_York Thu May 30 12:19:30 EDT 2002 <----- wrong, should be BST time (or error!) # date Thu May 30 17:19:35 BST 2002 Attached is a patch against revision 1.52 of ash.c which moves the checks so that checkalias is updated regardless of whether CONFIG_ASH_ALIAS is set. With this patch applied, the command shown above which should generate an error does generate an error. I have tested this patch with the 'dd' command too and that now works correctly. --- shell/ash.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 366f704be..3d7043c8f 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9967,8 +9967,8 @@ static int readtoken() { int t; -#ifdef CONFIG_ASH_ALIAS int savecheckalias = checkalias; +#ifdef CONFIG_ASH_ALIAS int savecheckkwd = checkkwd; struct alias *ap; #endif @@ -9983,9 +9983,7 @@ top: t = xxreadtoken(); -#ifdef CONFIG_ASH_ALIAS checkalias = savecheckalias; -#endif if (checkkwd) { /* @@ -10021,8 +10019,8 @@ top: } } else if (checkalias == 2 && isassignment(wordtext)) { lasttoken = t = TASSIGN; -#ifdef CONFIG_ASH_ALIAS } else if (checkalias) { +#ifdef CONFIG_ASH_ALIAS if (!quoteflag && (ap = *__lookupalias(wordtext)) != NULL && !(ap->flag & ALIASINUSE)) { if (*ap->val) { pushstring(ap->val, strlen(ap->val), ap); @@ -10030,8 +10028,8 @@ top: checkkwd = savecheckkwd; goto top; } - checkalias = 0; #endif + checkalias = 0; } out: #ifdef DEBUG @@ -12442,7 +12440,7 @@ findvar(struct var **vpp, const char *name) /* * Copyright (c) 1999 Herbert Xu * This file contains code for the times builtin. - * $Id: ash.c,v 1.53 2002/07/03 23:19:22 andersen Exp $ + * $Id: ash.c,v 1.54 2002/07/04 00:19:46 andersen Exp $ */ static int timescmd (int argc, char **argv) { -- cgit v1.2.3