summaryrefslogtreecommitdiff
path: root/flags.c
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2000-03-17 21:46:59 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:53 +0000
commitbb70624e964126b7ac4ff085ba163a9c35ffa18f (patch)
treeba2dd4add13ada94b1899c6d4aca80195b80b74b /flags.c
parentb72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (diff)
downloadbash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.gz
Imported from ../bash-2.04.tar.gz.
Diffstat (limited to 'flags.c')
-rw-r--r--flags.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/flags.c b/flags.c
index 19cd3b4e..9cb753a0 100644
--- a/flags.c
+++ b/flags.c
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Flags hacking. */
#include "config.h"
@@ -36,6 +36,9 @@ extern int set_job_control ();
extern char *shell_name;
#endif
+/* -c, -s invocation options -- not really flags, but they show up in $- */
+extern int want_pending_command, read_from_stdin;
+
/* **************************************************************** */
/* */
/* The Standard Sh Flags. */
@@ -219,14 +222,14 @@ change_flag (flag, on_or_off)
{
int *value, old_value;
- value = find_flag (flag);
-
#if defined (RESTRICTED_SHELL)
/* Don't allow "set +r" in a shell which is `restricted'. */
if (restricted && flag == 'r' && on_or_off == FLAG_OFF)
return (FLAG_ERROR);
#endif /* RESTRICTED_SHELL */
+ value = find_flag (flag);
+
if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
return (FLAG_ERROR);
@@ -275,11 +278,16 @@ which_set_flags ()
char *temp;
int i, string_index;
- temp = xmalloc (1 + NUM_SHELL_FLAGS);
+ temp = xmalloc (1 + NUM_SHELL_FLAGS + read_from_stdin + want_pending_command);
for (i = string_index = 0; shell_flags[i].name; i++)
if (*(shell_flags[i].value))
temp[string_index++] = shell_flags[i].name;
+ if (want_pending_command)
+ temp[string_index++] = 'c';
+ if (read_from_stdin)
+ temp[string_index++] = 's';
+
temp[string_index] = '\0';
return (temp);
}