]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Fix some HUSH problems.
authorwdenk <wdenk>
Sat, 20 Oct 2001 09:41:35 +0000 (09:41 +0000)
committerwdenk <wdenk>
Sat, 20 Oct 2001 09:41:35 +0000 (09:41 +0000)
In the current implementation, the local variables space and global
environment variables space are separated. Local variables are those
you define by simply typing like `name=value'. To access a local
variable later on, you have write `$name' or `${name}'; variable
directly by typing say `$name' at the command prompt.

Global environment variables are those you use setenv/printenv to
work with. To run a command stored in such a variable, you need to
use the run command, and you must not use the '$' sign to access
them.

To store commands and special characters in a variable, please use
double quotation marks surrounding the whole text of the variable,
instead of the backslashes before semicolons and special symbols.

NOTE: still serious quoting problems! cannot access env vars in commands!

CHANGELOG
README
common/cmd_autoscript.c
common/cmd_bootm.c
common/hush.c
common/main.c
include/config_TQM860L.h

index 2a932e387d14adff6a4ca1b5a9be8e796ded5604..f36606ec9df228b1dd36fda95ce6390ac060eb25 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -56,6 +56,9 @@ To do:
 Modifications for 1.1.0:
 ======================================================================
 
+* Add support for Fujitsu flash on TQM8260
+  Patch by Franz Sirl, 19 Oct 2001
+
 * Updated GTH Board
   Patch by Thomas Lange, 18 Oct 2001
 
@@ -67,6 +70,8 @@ Modifications for 1.1.0:
   if...then...else...fi conditionals or `&&' and '||' constructs
   ("shell scripts").
 
+  See the README file for information about implementation and usage.
+
 * Modified all commands to provide return codes that can be used for
   conditional command execution
 
diff --git a/README b/README
index b436f01410917fd9d4766386141669c2d99f62c7..8c0d406fb183d5801a66e196e67bea5ecd828069 100644 (file)
--- a/README
+++ b/README
@@ -648,6 +648,28 @@ The following options need to be configured:
                 printed when the command interpreter needs more input
                 to complete a command. Usually "> ".
 
+       Note:
+
+                In the current implementation, the local variables
+                space and global environment variables space are
+                separated. Local variables are those you define by
+                simply typing like `name=value'. To access a local
+                variable later on, you have write `$name' or
+                `${name}'; variable directly by typing say `$name' at
+                the command prompt.
+
+                Global environment variables are those you use
+                setenv/printenv to work with. To run a command stored
+                in such a variable, you need to use the run command,
+                and you must not use the '$' sign to access them.
+
+                To store commands and special characters in a
+                variable, please use double quotation marks
+                surrounding the whole text of the variable, instead
+                of the backslashes before semicolons and special
+                symbols.
+
+
 Configuration Settings:
 -----------------------
 
index da8b52bb78ca779ffe163547069e44a4fa14ba6e..ec73a0221854a2151f7ea3490737155fc9a86aa8 100644 (file)
 #if defined(CONFIG_AUTOSCRIPT) || \
         (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT)
 
+#ifdef CFG_HUSH_PARSER
+extern int parse_string_outer(char *s);
+#endif
+
 extern image_header_t header;          /* from cmd_bootm.c */
 int
 autoscript(bd_t *bd, ulong addr)
@@ -111,7 +115,11 @@ autoscript(bd_t *bd, ulong addr)
                        }
                }
        }
+#ifndef CFG_HUSH_PARSER        
        rcode = run_command(cmd, bd, 0);
+#else
+       rcode = parse_string_outer(cmd);
+#endif 
        free(cmd);
        return rcode;
 }
index ebd098b3b158032ecc67eaccccf9699b459117bd..798bc753c9c845b790dd35fb7a985eac8159bfa3 100644 (file)
@@ -34,6 +34,9 @@
 #include <rtc.h>
 #endif
 
+#ifdef CFG_HUSH_PARSER
+extern int parse_string_outer(char *s);
+#endif
 int  gunzip (void *, int, unsigned char *, int *);
 
 static void *zalloc(void *, unsigned, unsigned);
@@ -583,8 +586,11 @@ do_bootm_netbsd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
 int do_bootd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 {    
        int rcode = 0;
-         
+#ifndef CFG_HUSH_PARSER          
        if (run_command (getenv ("bootcmd"), bd, flag) == -1) rcode = 1;
+#else
+        if (parse_string_outer(getenv("bootcmd")) != 0 ) rcode = 1;    
+#endif 
        return rcode;
 }
 #endif
index 9a71af94afa6580b89220b1073973ffdb074474a..4a3ac86355a374889771d13f4d354bc5caba7e87 100644 (file)
@@ -290,11 +290,12 @@ static unsigned int last_jobid;
 static unsigned int shell_terminal;
 static char *PS1;
 static char *PS2;
-#else
-static bd_t *BD;
-#endif 
 struct variables shell_ver = { "HUSH_VERSION", "0.01", 1, 1, 0 };
 struct variables *top_vars = &shell_ver;
+#else
+static bd_t *BD;
+static struct variables *top_vars ;
+#endif /*__PPCBOOT__ */
 
 #define B_CHUNK (100)
 #define B_NOSPAC 1
@@ -450,11 +451,13 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
 static int parse_string(o_string *dest, struct p_context *ctx, const char *src);
 static int parse_stream(o_string *dest, struct p_context *ctx, struct in_str *input0, int end_trigger);
 /*   setup: */
-static int parse_stream_outer(struct in_str *inp);
 #ifndef __PPCBOOT__
+static int parse_stream_outer(struct in_str *inp);
 static int parse_string_outer(const char *s);
 static int parse_file_outer(FILE *f);
 #else
+static int parse_stream_outer(struct in_str *inp, int end);
+int parse_string_outer(char *s);
 int ppcboot_hush_start(bd_t *bd);
 static int parse_file_outer(void);
 #endif
@@ -870,11 +873,13 @@ static void b_free(o_string *o)
  */
 static int b_addqchr(o_string *o, int ch, int quote)
 {
+#ifndef __PPCBOOT__
        if (quote && strchr("*?[\\",ch)) {
                int rc;
                rc = b_addchr(o, '\\');
                if (rc) return rc;
        }
+#endif /* __PPCBOOT__ */
        return b_addchr(o, ch);
 }
 
@@ -2814,12 +2819,17 @@ void update_ifs_map(void)
 
 /* most recursion does not come through here, the exeception is
  * from builtin_source() */
+#ifndef __PPCBOOT__
 int parse_stream_outer(struct in_str *inp)
+#else
+int parse_stream_outer(struct in_str *inp, int end)
+#endif /* __PPCBOOT__ */
 {
 
        struct p_context ctx;
        o_string temp=NULL_O_STRING;
        int rcode;
+
        do {
                initialize_context(&ctx);
                update_ifs_map();
@@ -2842,18 +2852,31 @@ int parse_stream_outer(struct in_str *inp)
                free_pipe_list(ctx.list_head,0);
                b_free(&temp);                          
                }
-#endif         
+    } while (end != 1);
+       return (rcode != 1) ? 0 : 1;
+#else
        } while (rcode != -1);   /* loop on syntax errors, return on EOF */
        return 0;
+#endif /* __PPCBOOT__ */
 }
 #ifndef __PPCBOOT__
 static int parse_string_outer(const char *s)
+#else
+int parse_string_outer(char *s)
+#endif /* __PPCBOOT__ */
 {
        struct in_str input;
+
        setup_string_in_str(&input, s);
+#ifdef __PPCBOOT__
+       if ( !s || !*s)
+               return 1;
+    return parse_stream_outer(&input, 1);
+#else
        return parse_stream_outer(&input);
+#endif /* __PPCBOOT__ */
 }
-#endif
+
 #ifndef __PPCBOOT__
 static int parse_file_outer(FILE *f)
 #else
@@ -2864,23 +2887,31 @@ static int parse_file_outer(void)
        struct in_str input;
 #ifndef __PPCBOOT__    
        setup_file_in_str(&input, f);
-#else
-        setup_file_in_str(&input);
-#endif         
        rcode = parse_stream_outer(&input);
+#else
+    setup_file_in_str(&input);
+       rcode = parse_stream_outer(&input, 0);
+#endif /* __PPCBOOT__ */
        return rcode;
 }
-#ifdef __PPCBOOT__
 
+#ifdef __PPCBOOT__
 int ppcboot_hush_start(bd_t *bd)
 {
-   extern bd_t *BD;
+    extern bd_t *BD;
    
-   BD = bd;
-   parse_file_outer();
-   return 1;
-}
-#endif
+    BD = bd;
+       top_vars = malloc(sizeof(struct variables));
+       top_vars->name = "HUSH_VERSION";
+       top_vars->value = "0.01";
+       top_vars->next = 0;
+       top_vars->flg_export = 0;
+       top_vars->flg_read_only = 1;
+    parse_file_outer();
+    return 1;
+}
+#endif /* __PPCBOOT__ */
+
 #ifndef __PPCBOOT__
 /* Make sure we have a controlling tty.  If we get started under a job
  * aware app (like bash for example), make sure we are now in charge so
index c57520278333279482a2c8c357944315d52e6c17..18d0e5be2c1a58614a36a6782b2280dfdd11077f 100644 (file)
 #include <command.h>
 #include <cmd_nvedit.h>
 #include <cmd_bootm.h>
+#include <malloc.h>
 #if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
 #include <cmd_boot.h>          /* for do_reset() prototype */
 #endif
 
 #ifdef CFG_HUSH_PARSER  
-int ppcboot_hush_start(bd_t *bd);
+extern int ppcboot_hush_start(bd_t *bd);
+extern int parse_string_outer(char *s);
 #endif
 
 static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
@@ -710,9 +712,12 @@ int do_run (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
        }
 
        for (i=1; i<argc; ++i) {
-           if (run_command (getenv (argv[i]), bd, flag) != -1) rcode = 1;
+#ifndef CFG_HUSH_PARSER        
+           if (run_command (getenv (argv[i]), bd, flag) != -1) ++rcode;
+#else      
+           if (parse_string_outer(getenv (argv[i])) == 0) ++rcode;
+#endif     
        }
-       if (rcode == i) return 0;
-       return rcode;
+       return ((rcode == i) ? 0 : 1);
 }
 #endif
index ef056cb4f77227f7bcc8127605408f7046e0abb6..595d450ac7b8cf5876c54f15d7ca7cb18b28f66d 100644 (file)
@@ -76,6 +76,7 @@
 #define        CONFIG_RTC_MPC8xx               /* use internal RTC of MPC8xx   */
 
 #define CONFIG_COMMANDS              ( CONFIG_CMD_DFL  | \
+                               CFG_CMD_ASKENV  | \
                                CFG_CMD_DHCP    | \
                                CFG_CMD_IDE     | \
                                CFG_CMD_DATE    )
@@ -89,7 +90,7 @@
 #define        CFG_LONGHELP                    /* undef to save memory         */
 #define        CFG_PROMPT              "=> "   /* Monitor Command Prompt       */
 
-#define        CFG_HUSH_PARSER
+#define        CFG_HUSH_PARSER         1       /* use "hush" command parser    */
 #ifdef CFG_HUSH_PARSER
 #define        CFG_PROMPT_HUSH_PS2     "> "
 #endif