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
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"
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. */
disallows: changing directories, command or path names containing `/',
unsetting or resetting the values of $PATH and $SHELL, and any type of
output redirection. */
-int restricted = 0;
+int restricted = 0; /* currently restricted */
+int restricted_shell = 0; /* shell was started in restricted mode. */
#endif /* RESTRICTED_SHELL */
/* Non-zero means that this shell is running in `privileged' mode. This
{
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);
#if defined (RESTRICTED_SHELL)
case 'r':
if (on_or_off == FLAG_ON)
- maybe_make_restricted (shell_name);
+ maybe_make_restricted (shell_name);
break;
#endif
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);
}