Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/shell/hush.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1178 by niro, Wed Aug 18 22:00:50 2010 UTC revision 1179 by niro, Wed Dec 15 21:33:41 2010 UTC
# Line 1853  static void o_addblock_duplicate_backsla Line 1853  static void o_addblock_duplicate_backsla
1853   while (len) {   while (len) {
1854   o_addchr(o, *str);   o_addchr(o, *str);
1855   if (*str++ == '\\'   if (*str++ == '\\'
1856   && (*str != '*' && *str != '?' && *str != '[')  // && (*str != '*' && *str != '?' && *str != '[')
1857   ) {   ) {
1858   o_addchr(o, '\\');   o_addchr(o, '\\');
1859   }   }
# Line 2834  static NOINLINE int expand_vars_to_list( Line 2834  static NOINLINE int expand_vars_to_list(
2834   return n;   return n;
2835  }  }
2836    
2837  static char **expand_variables(char **argv, int or_mask)  enum {
2838     EXPVAR_FLAG_GLOB = 0x200,
2839     EXPVAR_FLAG_ESCAPE_VARS = 0x100,
2840     EXPVAR_FLAG_SINGLEWORD = 0x80, /* must be 0x80 */
2841    };
2842    static char **expand_variables(char **argv, unsigned or_mask)
2843  {  {
2844   int n;   int n;
2845   char **list;   char **list;
2846   char **v;   char **v;
2847   o_string output = NULL_O_STRING;   o_string output = NULL_O_STRING;
2848    
2849   if (or_mask & 0x100) {   /* protect against globbing for "$var"? */
2850   output.o_escape = 1; /* protect against globbing for "$var" */   /* (unquoted $var will temporarily switch it off) */
2851   /* (unquoted $var will temporarily switch it off) */   output.o_escape = 1 & (or_mask / EXPVAR_FLAG_ESCAPE_VARS);
2852   output.o_glob = 1;   output.o_glob = 1 & (or_mask / EXPVAR_FLAG_GLOB);
  }  
2853    
2854   n = 0;   n = 0;
2855   v = argv;   v = argv;
# Line 2863  static char **expand_variables(char **ar Line 2867  static char **expand_variables(char **ar
2867    
2868  static char **expand_strvec_to_strvec(char **argv)  static char **expand_strvec_to_strvec(char **argv)
2869  {  {
2870   return expand_variables(argv, 0x100);   return expand_variables(argv, EXPVAR_FLAG_GLOB | EXPVAR_FLAG_ESCAPE_VARS);
2871  }  }
2872    
2873  #if ENABLE_HUSH_BASH_COMPAT  #if ENABLE_HUSH_BASH_COMPAT
2874  static char **expand_strvec_to_strvec_singleword_noglob(char **argv)  static char **expand_strvec_to_strvec_singleword_noglob(char **argv)
2875  {  {
2876   return expand_variables(argv, 0x80);   return expand_variables(argv, EXPVAR_FLAG_SINGLEWORD);
2877  }  }
2878  #endif  #endif
2879    
# Line 2909  static char **expand_strvec_to_strvec_si Line 2913  static char **expand_strvec_to_strvec_si
2913  #endif  #endif
2914    
2915  /* Used for expansion of right hand of assignments */  /* Used for expansion of right hand of assignments */
2916  /* NB: should NOT do globbing! "export v=/bin/c*; env | grep ^v=" outputs  /* NB: should NOT do globbing!
2917   * "v=/bin/c*" */   * "export v=/bin/c*; env | grep ^v=" outputs "v=/bin/c*" */
2918  static char *expand_string_to_string(const char *str)  static char *expand_string_to_string(const char *str)
2919  {  {
2920   char *argv[2], **list;   char *argv[2], **list;
2921    
2922   argv[0] = (char*)str;   argv[0] = (char*)str;
2923   argv[1] = NULL;   argv[1] = NULL;
2924   list = expand_variables(argv, 0x80); /* 0x80: singleword expansion */   list = expand_variables(argv, EXPVAR_FLAG_ESCAPE_VARS | EXPVAR_FLAG_SINGLEWORD);
2925   if (HUSH_DEBUG)   if (HUSH_DEBUG)
2926   if (!list[0] || list[1])   if (!list[0] || list[1])
2927   bb_error_msg_and_die("BUG in varexp2");   bb_error_msg_and_die("BUG in varexp2");
# Line 2933  static char* expand_strvec_to_string(cha Line 2937  static char* expand_strvec_to_string(cha
2937  {  {
2938   char **list;   char **list;
2939    
2940   list = expand_variables(argv, 0x80);   list = expand_variables(argv, EXPVAR_FLAG_SINGLEWORD);
2941   /* Convert all NULs to spaces */   /* Convert all NULs to spaces */
2942   if (list[0]) {   if (list[0]) {
2943   int n = 1;   int n = 1;

Legend:
Removed from v.1178  
changed lines
  Added in v.1179