diff options
author | Jari Aalto <jari.aalto@cante.net> | 1997-06-05 14:59:13 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:50 +0000 |
commit | d166f048818e10cf3799aa24a174fb22835f1acc (patch) | |
tree | 1ca27f9243900f8b236d0cde6a3862002aea9e19 /builtins/set.def | |
parent | ccc6cda312fea9f0468ee65b8f368e9653e1380b (diff) | |
download | bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.gz |
Imported from ../bash-2.01.tar.gz.
Diffstat (limited to 'builtins/set.def')
-rw-r--r-- | builtins/set.def | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/builtins/set.def b/builtins/set.def index d31e77e8..74f2e5cd 100644 --- a/builtins/set.def +++ b/builtins/set.def @@ -78,6 +78,9 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] #if defined (BANG_HISTORY) histexpand same as -H #endif /* BANG_HISTORY */ +#if defined (HISTORY) + history enable command history +#endif ignoreeof the shell will not exit upon reading EOF interactive-comments allow comments to appear in interactive commands @@ -110,12 +113,12 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] #if defined (BRACE_EXPANSION) -B the shell will perform brace expansion #endif /* BRACE_EXPANSION */ + -C If set, disallow existing regular files to be overwritten + by redirection of output. #if defined (BANG_HISTORY) -H Enable ! style history substitution. This flag is on by default. #endif /* BANG_HISTORY */ - -C If set, disallow existing regular files to be overwritten - by redirection of output. -P If set, do not follow symbolic links when executing commands such as cd which change the current directory. @@ -127,6 +130,7 @@ ARGs are given, all shell variables are printed. $END static int set_ignoreeof (); +static int set_posix_mode (); #if defined (READLINE) static int set_edit_mode (); @@ -183,7 +187,7 @@ struct { #endif { "ignoreeof", &ignoreeof, set_ignoreeof, (Function *)NULL }, { "interactive-comments", &interactive_comments, (Function *)NULL, (Function *)NULL }, - { "posix", &posixly_correct, (Function *)NULL, (Function *)NULL }, + { "posix", &posixly_correct, set_posix_mode, (Function *)NULL }, #if defined (READLINE) { "emacs", (int *)NULL, set_edit_mode, get_edit_mode }, { "vi", (int *)NULL, set_edit_mode, get_edit_mode }, @@ -283,6 +287,20 @@ set_ignoreeof (on_or_off, option_name) return 0; } +static int +set_posix_mode (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + posixly_correct = on_or_off == FLAG_ON; + if (posixly_correct == 0) + unbind_variable ("POSIXLY_CORRECT"); + else + bind_variable ("POSIXLY_CORRECT", "y"); + sv_strict_posix ("POSIXLY_CORRECT"); + return (0); +} + #if defined (READLINE) /* Magic. This code `knows' how readline handles rl_editing_mode. */ static int @@ -435,7 +453,9 @@ set_shellopts () vptr += strlen (binary_o_options[i].name); value[vptr++] = ':'; } - value[--vptr] = '\0'; /* cut off trailing colon */ + if (vptr) + vptr--; /* cut off trailing colon */ + value[vptr] = '\0'; v = find_variable ("SHELLOPTS"); if (v) @@ -465,15 +485,34 @@ void initialize_shell_options () { char *temp; + SHELL_VAR *var; + var = find_variable ("SHELLOPTS"); /* set up any shell options we may have inherited. */ - if (temp = get_string_value ("SHELLOPTS")) - parse_shellopts (temp); + if (var && imported_p (var)) + { + temp = (array_p (var)) ? (char *)NULL : savestring (value_cell (var)); + if (temp) + { + parse_shellopts (temp); + free (temp); + } + } /* Set up the $SHELLOPTS variable. */ set_shellopts (); } +/* Reset the values of the -o options that are not also shell flags. */ +void +reset_shell_options () +{ +#if defined (HISTORY) + remember_on_history = 1; +#endif + ignoreeof = posixly_correct = 0; +} + /* Set some flags from the word values in the input list. If LIST is empty, then print out the values of the variables instead. If LIST contains non-flags, then set $1 - $9 to the successive words of LIST. */ @@ -691,6 +730,12 @@ unset_builtin (list) } #endif + if (legal_identifier (name) == 0) + { + builtin_error ("`%s': not a valid identifier", name); + NEXT_VARIABLE (); + } + var = unset_function ? find_function (name) : find_variable (name); if (var && !unset_function && non_unsettable_p (var)) |