diff options
Diffstat (limited to 'builtins')
-rw-r--r-- | builtins/declare.def | 47 | ||||
-rw-r--r-- | builtins/evalfile.c | 2 | ||||
-rw-r--r-- | builtins/evalstring.c | 12 | ||||
-rw-r--r-- | builtins/gen-helpfiles.c | 10 | ||||
-rw-r--r-- | builtins/jobs.def | 2 | ||||
-rw-r--r-- | builtins/printf.def | 15 | ||||
-rw-r--r-- | builtins/setattr.def | 4 |
7 files changed, 57 insertions, 35 deletions
diff --git a/builtins/declare.def b/builtins/declare.def index 580e3fa8..a634e7ce 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -143,7 +143,7 @@ declare_internal (list, local_var) int flags_on, flags_off, *flags; int any_failed, assign_error, pflag, nodefs, opt, mkglobal, onref, offref; char *t, *subscript_start; - SHELL_VAR *var, *refvar; + SHELL_VAR *var, *refvar, *v; FUNCTION_DEF *shell_fn; flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0; @@ -375,31 +375,7 @@ declare_internal (list, local_var) var = make_local_array_variable (name, making_array_special); else #endif -#if 0 - /* XXX - this doesn't work right yet. */ - /* See below for rationale for doing this. */ - if (flags_on & att_nameref) - { - /* See if we are trying to modify an existing nameref variable */ - var = find_variable_last_nameref (name); - if (var && nameref_p (var) == 0) - var = make_local_variable (name); - } - else if (flags_off & att_nameref) - { - var = (SHELL_VAR *)NULL; - /* See if we are trying to modify an existing nameref variable */ - refvar = find_variable_last_nameref (name); - if (refvar && nameref_p (refvar) == 0) - refvar = 0; - if (refvar) - var = make_local_variable (nameref_cell (refvar)); - if (var == 0) - var = make_local_variable (name); - } - else -#endif - var = make_local_variable (name); + var = make_local_variable (name); /* sets att_invisible for new vars */ if (var == 0) { any_failed++; @@ -534,6 +510,11 @@ declare_internal (list, local_var) assign_error++; NEXT_VARIABLE (); } + else if (flags_on & att_nameref) + { + /* ksh93 compat: turning on nameref attribute turns off -ilu */ + VUNSETATTR (var, att_integer|att_uppercase|att_lowercase|att_capcase); + } /* Cannot use declare +r to turn off readonly attribute. */ if (readonly_p (var) && (flags_off & att_readonly)) @@ -651,7 +632,19 @@ declare_internal (list, local_var) /* bind_variable_value duplicates the essential internals of bind_variable() */ if (offset) - bind_variable_value (var, value, aflags); + { + if (onref) + aflags |= ASS_NAMEREF; + v = bind_variable_value (var, value, aflags); + if (v == 0 && onref) + { + sh_invalidid (value); + assign_error++; + /* XXX - unset this variable? or leave it as normal var? */ + delete_var (var->name, mkglobal ? global_variables : shell_variables); + NEXT_VARIABLE (); + } + } /* If we found this variable in the temporary environment, as with `var=value declare -x var', make sure it is treated identically diff --git a/builtins/evalfile.c b/builtins/evalfile.c index a59ce597..058d99da 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -109,7 +109,7 @@ _evalfile (filename, flags) GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a); # endif #endif - + fd = open (filename, O_RDONLY); if (fd < 0 || (fstat (fd, &finfo) == -1)) diff --git a/builtins/evalstring.c b/builtins/evalstring.c index a78688cc..671ab5d7 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -159,6 +159,9 @@ parse_prologue (string, flags, tag) } add_unwind_protect (pop_stream, (char *)NULL); + if (parser_expanding_alias ()) + add_unwind_protect (parser_restore_alias, (char *)NULL); + if (orig_string && ((flags & SEVAL_NOFREE) == 0)) add_unwind_protect (xfree, orig_string); end_unwind_frame (); @@ -211,6 +214,10 @@ parse_and_execute (string, from_file, flags) before executing the next command (resetting the line number sets it to 0; the first line number is 1). */ push_stream (lreset); + if (parser_expanding_alias ()) + /* push current shell_input_line */ + parser_save_alias (); + if (lreset == 0) line_number--; @@ -432,7 +439,10 @@ parse_string (string, from_file, flags, endp) before executing the next command (resetting the line number sets it to 0; the first line number is 1). */ push_stream (0); - + if (parser_expanding_alias ()) + /* push current shell_input_line */ + parser_save_alias (); + code = should_jump_to_top_level = 0; oglobal = global_command; ostring = string; diff --git a/builtins/gen-helpfiles.c b/builtins/gen-helpfiles.c index b3144974..fac34edf 100644 --- a/builtins/gen-helpfiles.c +++ b/builtins/gen-helpfiles.c @@ -59,6 +59,14 @@ #include "../builtins.h" #include "tmpbuiltins.h" +#if defined (USING_BASH_MALLOC) +#undef xmalloc +#undef xrealloc +#undef xfree + +#undef free /* defined in xmalloc.h */ +#endif + #ifndef errno extern int errno; #endif @@ -90,7 +98,7 @@ char *helpfile_directory; /* Forward declarations. */ -int write_helpfiles (); +int write_helpfiles __P((struct builtin *)); /* For each file mentioned on the command line, process it and write the information to STRUCTFILE and EXTERNFILE, while diff --git a/builtins/jobs.def b/builtins/jobs.def index b14e91f2..47da58e4 100644 --- a/builtins/jobs.def +++ b/builtins/jobs.def @@ -31,7 +31,7 @@ Without options, the status of all active jobs is displayed. Options: -l lists process IDs in addition to the normal information - -n list only processes that have changed status since the last + -n lists only processes that have changed status since the last notification -p lists process IDs only -r restrict output to running jobs diff --git a/builtins/printf.def b/builtins/printf.def index cf33f6be..7f29126d 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -765,7 +765,7 @@ printstr (fmt, string, len, fieldwidth, precision) /* If we remove this, get rid of `s'. */ if (*fmt != 'b' && *fmt != 'q') { - internal_error ("format parsing problem: %s", s); + internal_error (_("format parsing problem: %s"), s); fw = pr = 0; } #endif @@ -1252,12 +1252,19 @@ bind_printf_variable (name, value, flags) char *value; int flags; { + SHELL_VAR *v; + #if defined (ARRAY_VARS) if (valid_array_reference (name) == 0) - return (bind_variable (name, value, flags)); + v = bind_variable (name, value, flags); else - return (assign_array_element (name, value, flags)); + v = assign_array_element (name, value, flags); #else /* !ARRAY_VARS */ - return bind_variable (name, value, flags); + v = bind_variable (name, value, flags); #endif /* !ARRAY_VARS */ + + if (v && readonly_p (v) == 0 && noassign_p (v) == 0) + VUNSETATTR (v, att_invisible); + + return v; } diff --git a/builtins/setattr.def b/builtins/setattr.def index 390b3eb1..3be31896 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -455,7 +455,11 @@ show_name_attributes (name, nodefs) { SHELL_VAR *var; +#if 0 var = find_variable_tempenv (name); +#else + var = find_variable_noref (name); +#endif if (var && invisible_p (var) == 0) { |