]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - shell.c
commit bash-20100204 snapshot
[thirdparty/bash.git] / shell.c
diff --git a/shell.c b/shell.c
index 8dadb0b4468ec437b88afc7b68063ebc9b5681d8..9074050d4a3231f33b4868bb0b08b2622c5981df 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -226,7 +226,6 @@ int posixly_correct = 1;    /* Non-zero means posix.2 superset. */
 int posixly_correct = 0;       /* Non-zero means posix.2 superset. */
 #endif
 
-
 /* Some long-winded argument names.  These are obviously new. */
 #define Int 1
 #define Charp 2
@@ -271,6 +270,8 @@ int subshell_argc;
 char **subshell_argv;
 char **subshell_envp;
 
+char *exec_argv0;
+
 #if defined (BUFFERED_INPUT)
 /* The file descriptor from which the shell is reading input. */
 int default_buffered_input = -1;
@@ -1415,7 +1416,12 @@ open_shell_script (script_name)
     }
 
   free (dollar_vars[0]);
-  dollar_vars[0] = savestring (script_name);
+  dollar_vars[0] = exec_argv0 ? savestring (exec_argv0) : savestring (script_name);
+  if (exec_argv0)
+    {
+      free (exec_argv0);
+      exec_argv0 = (char *)NULL;
+    }
 
 #if defined (ARRAY_VARS)
   GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
@@ -1719,8 +1725,9 @@ shell_initialize ()
   initialize_flags ();
 
   /* Initialize the shell options.  Don't import the shell options
-     from the environment variable $SHELLOPTS if we are running in
-     privileged or restricted mode or if the shell is running setuid. */
+     from the environment variables $SHELLOPTS or $BASHOPTS if we are
+     running in privileged or restricted mode or if the shell is running
+     setuid. */
 #if defined (RESTRICTED_SHELL)
   initialize_shell_options (privileged_mode||restricted||running_setuid);
   initialize_bashopts (privileged_mode||restricted||running_setuid);