=diff -r -c bash-1_14_7/.distribution bash1147/.distribution8*** bash-1_14_7/.distribution Wed Mar 10 09:43:44 19995--- bash1147/.distribution Wed Mar 10 09:44:50 1999*************** *** 1 ****! 1.14 --- 1 ----! 1.157diff -r -c bash-1_14_7/bashhist.c bash1147/bashhist.c5*** bash-1_14_7/bashhist.c Wed Mar 10 09:43:45 19992--- bash1147/bashhist.c Fri Mar 19 17:36:13 1999****************** 106,111 ****--- 106,114 ----? /* Read the history in HISTFILE into the history list. */) hf = get_string_value ("HISTFILE"); + #if defined (USE_VMS)1+ hf = vmsutil_expand_path (savestring (hf)); + #endif if (hf && *hf)  { struct stat buf;****************** 117,122 ****--- 120,129 ----0 history_lines_in_file = where_history (); }  }+ #if defined (USE_VMS) + if (hf)+ free (hf); + #endif } = /* Write the existing history out to the history file. */****************** 125,130 ****--- 132,140 ---- {/ char *hf = get_string_value ("HISTFILE"); + #if defined (USE_VMS)1+ hf = vmsutil_expand_path (savestring (hf)); + #endif if (hf && *hf)  { struct stat buf;****************** 141,146 ****--- 151,160 ---- write_history (hf); }  }+ #if defined (USE_VMS) + if (hf)+ free (hf); + #endif } F /* If this is an interactive shell, then append the lines executed****************** 154,159 ****--- 168,176 ----  {3 char *hf = get_string_value ("HISTFILE"); + #if defined (USE_VMS)5+ hf = vmsutil_expand_path (savestring (hf)); + #endif if (hf && *hf) { struct stat buf;****************** 182,187 ****--- 199,208 ----  }& history_lines_this_session = 0; }+ #if defined (USE_VMS)+ if (hf)+ free (hf); + #endif  } return (result); }Adiff -r -c bash-1_14_7/builtins/cd.def bash1147/builtins/cd.def:*** bash-1_14_7/builtins/cd.def Wed Mar 10 09:43:50 19997--- bash1147/builtins/cd.def Wed Mar 10 09:45:00 1999****************** 22,28 ****--- 22,30 ---- $PRODUCES cd.c  #include + #ifndef VMS #include + #endif  #if defined (HAVE_STRING_H) # include Ediff -r -c bash-1_14_7/builtins/exit.def bash1147/builtins/exit.def<*** bash-1_14_7/builtins/exit.def Wed Mar 10 09:43:51 19999--- bash1147/builtins/exit.def Fri Mar 19 15:18:18 1999****************** 37,42 ****--- 37,47 ---- ( extern int interactive, login_shell;' extern int last_command_exit_value;+ #if defined (USE_VMS) + int subshell_exit_value = 0;"+ int subshell_exit_builtin = 0;#+ int subshell_skip_commands = 0; + #endif ! static int exit_or_logout ();" static int sourced_logout = 0;****************** 120,129 ****--- 125,149 ---- R /* Run our `~/.bash_logout' file if it exists, and this is a login shell. *// if (login_shell && sourced_logout++ == 0)+ #if defined (USE_VMS)B+ if (maybe_execute_file ("sys$login:.bash_logout", 1) == 0)D+ if (maybe_execute_file ("sys$login:_bash_logout", 1) == 0)9+ maybe_execute_file ("sys$login:_blogout", 1); + #else1 maybe_execute_file ("~/.bash_logout", 1); + #endif + last_command_exit_value = exit_value;  /* Exit the program. */+ #if defined (USE_VMS) + if (subshell_exit_builtin) + {++ subshell_exit_value = exit_value;$+ subshell_exit_builtin = 0;%+ subshell_skip_commands = 1;%+ return (EXECUTION_SUCCESS); + } + #endif$ longjmp (top_level, EXITPROG); }Adiff -r -c bash-1_14_7/builtins/fc.def bash1147/builtins/fc.def:*** bash-1_14_7/builtins/fc.def Wed Mar 10 09:43:51 19997--- bash1147/builtins/fc.def Wed Mar 10 09:45:02 1999****************** 50,59 ****--- 50,65 ---- #include "../bashansi.h" #include "../shell.h" #if defined (HISTORY)+ #ifdef VMS+ #include + #include + #include + #else #include  #include  #include  #include + #endif #include  #include "../builtins.h" #include "../flags.h"Kdiff -r -c bash-1_14_7/builtins/history.def bash1147/builtins/history.def?*** bash-1_14_7/builtins/history.def Wed Mar 10 09:43:51 1999<--- bash1147/builtins/history.def Wed Mar 10 09:45:03 1999****************** 37,44 ****--- 37,49 ----  #include "../shell.h" #if defined (HISTORY)+ #ifdef VMS+ #include + #include + #else #include  #include + #endif #include "../filecntl.h" #include "../posixstat.h" #include "../bashhist.h"Mdiff -r -c bash-1_14_7/builtins/mkbuiltins.c bash1147/builtins/mkbuiltins.c@*** bash-1_14_7/builtins/mkbuiltins.c Wed Mar 10 09:43:52 1999=--- bash1147/builtins/mkbuiltins.c Wed Mar 10 09:45:04 1999****************** 231,240 ****--- 231,247 ----  if (structfile) {+ char buff [256];3 write_longdocs (structfile, saved_builtins); fclose (structfile);+ #if defined (VMS)&+ sprintf (buff, "rename %s. %s",0+ temp_struct_filename, struct_filename);+ system (buff); + #else4 link (temp_struct_filename, struct_filename);% unlink (temp_struct_filename); + #endif }  if (externfile)****************** 500,506 ****  else7 fprintf (defs->output, "#line %d \"%s%s\"\n"," defs->line_number + 1,5! error_directory ? error_directory : "./", defs->filename);! output_cpp_line_info = 0; }--- 507,513 ----  else7 fprintf (defs->output, "#line %d \"%s%s\"\n"," defs->line_number + 1,3! error_directory ? error_directory : "", defs->filename);! output_cpp_line_info = 0; }****************** 840,846 ****$ char *format, *arg1, *arg2; {# if (defs->filename[0] != '/')I! fprintf (stderr, "%s", error_directory ? error_directory : "./");H fprintf (stderr, "%s:%d:", defs->filename, defs->line_number + 1);+ fprintf (stderr, format, arg1, arg2); fprintf (stderr, "\n");--- 847,853 ----$ char *format, *arg1, *arg2; {# if (defs->filename[0] != '/')G! fprintf (stderr, "%s", error_directory ? error_directory : "");H fprintf (stderr, "%s:%d:", defs->filename, defs->line_number + 1);+ fprintf (stderr, format, arg1, arg2); fprintf (stderr, "\n");Ediff -r -c bash-1_14_7/builtins/psize.sh bash1147/builtins/psize.sh<*** bash-1_14_7/builtins/psize.sh Wed Mar 10 09:43:52 19999--- bash1147/builtins/psize.sh Wed Mar 10 09:45:04 1999****************** 11,17 **** echo " */"  echo "" )! ./psize.aux 2>/tmp/pipesize | sleep 3 ! if [ -s /tmp/pipesize ]; then0 echo "#define PIPESIZE `cat /tmp/pipesize`"--- 11,17 ---- echo " */"  echo "" )! ./psize.exe 2>/tmp/pipesize | sleep 3 ! if [ -s /tmp/pipesize ]; then0 echo "#define PIPESIZE `cat /tmp/pipesize`"Idiff -r -c bash-1_14_7/builtins/source.def bash1147/builtins/source.def>*** bash-1_14_7/builtins/source.def Wed Mar 10 09:43:52 1999;--- bash1147/builtins/source.def Wed Mar 10 09:45:05 1999****************** 98,104 ****  {" char *string, *filename; struct stat finfo;! int fd, tt; 7 filename = find_path_file (list->word->word); if (!filename)--- 98,104 ----  {" char *string, *filename; struct stat finfo;! int fd, tt, pos; 7 filename = find_path_file (list->word->word);i if (!filename)******************* 108,120 **** goto file_error_exit; < string = (char *)xmalloc (1 + (int)finfo.st_size);0! tt = read (fd, string, finfo.st_size);'! string[finfo.st_size] = '\0';6 C /* Close the open file, preserving the state of errno. */ 9 { int temp = errno; close (fd); errno = temp; } " if (tt != finfo.st_size) { free (string);S --- 108,127 ---- goto file_error_exit; < string = (char *)xmalloc (1 + (int)finfo.st_size);! pos = 0;D! while ((tt = read (fd, &string [pos], finfo.st_size)) > 0)! pos += tt;s! string [pos] = '\0';! tt = pos;S C /* Close the open file, preserving the state of errno. */i9 { int temp = errno; close (fd); errno = temp; }* + #if defined (USE_VMS)+ if (tt < 0) + #elseh" if (tt != finfo.st_size) + #endif { free (string);  Idiff -r -c bash-1_14_7/builtins/ulimit.def bash1147/builtins/ulimit.def>*** bash-1_14_7/builtins/ulimit.def Wed Mar 10 09:43:53 1999;--- bash1147/builtins/ulimit.def Wed Mar 10 09:45:06 1999f*************** *** 52,59 ****--- 52,63 ---- $END  #include + #ifdef VMS+ #include + #elses #include  #include + #endif #include  #include "../shell.h"  #include "pipesize.h" *************** *** 138,143 ****--- 142,151 ----$ static void print_all_limits ();  static char t[2]; + + #if defined (USE_VMS)r)+ static RLIMTYPE ulimit () {return 0;}8 + #endif K /* Return 1 if the limit associated with CMD can be raised from CURRENT L to NEW. This is for USG systems without HAVE_RESOURCE, most of which5diff -r -c bash-1_14_7/command.h bash1147/command.hs4*** bash-1_14_7/command.h Wed Mar 10 09:43:45 19991--- bash1147/command.h Wed Mar 10 09:44:52 1999 ***************7*** 45,50 ****--- 45,53 ----% or backslash is present. */ B int assignment; /* Non-zero means that this word contains an assignment. */+ #if defined (USE_VMS)<+ int expansion; /* path expansion for "/" and "//x/" */ + #endif } WORD_DESC; ! /* A linked list of words. */l3diff -r -c bash-1_14_7/config.h bash1147/config.he3*** bash-1_14_7/config.h Wed Mar 10 09:43:45 1999d0--- bash1147/config.h Wed Mar 10 09:44:52 1999****************** 47,52 ****--- 47,56 ----& # endif /* !_POSIX_JOB_CONTROL */& #endif /* USG || Minix || MINIX */ + #if defined (USE_VMS)l+ # undef JOB_CONTROL + #endif+ 6 /* Define ALIAS if you want the alias features. */ #define ALIASc ****************** 89,96 ****--- 93,105 ----  #endif 1 /* The default value of the PATH variable. */ + #if defined (USE_VMS) + #define DEFAULT_PATH_VALUE \+ "/gnu/bin:/bin:."( + #else  #define DEFAULT_PATH_VALUE \< "/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:." + #endif M /* The value for PATH when invoking `command -p'. This is only used whenM the Posix.2 confstr () function, or CS_PATH define are not present. */ =diff -r -c bash-1_14_7/execute_cmd.c bash1147/execute_cmd.c8*** bash-1_14_7/execute_cmd.c Wed Mar 10 09:43:46 19995--- bash1147/execute_cmd.c Fri Mar 19 17:49:29 1999 ***************_*** 33,39 ****--- 33,41 ---- #define SIGABRT SIGIOT  #endif + #if !defined (VMS) #include + #endif #include   #if !defined (errno)***************m*** 46,53 ****--- 48,64 ---- # include  #endif /* !HAVE_STRING_H */e + #ifdef VMS+ #include + #include + #endif+  #include "shell.h"+ #if defined (VMS)*+ #include "y_tab.h" + #else- #include "y.tab.h" + #endif #include "flags.h" #include "hash.h"O #include "jobs.h"***************>*** 92,97 ****--- 103,124 ----D static int execute_builtin_or_function (), add_undo_redirect ();N static char *find_user_command_internal (), *find_user_command_in_path (); + #if defined (USE_VMS)e+ #include c+ #include "vmsutil.h"+ #include "trap.h"t1+ static int check_batch_file (char *filename);*E+ static void expand_words_for_internal_command (WORD_LIST *words);hU+ static void expand_arguments_for_external_command (WORD_LIST *words, char **args,*+ char **except);V+ static void maybe_expand_arguments (WORD_LIST *words, char *command, char **args);J+ extern char *extract_unit (char *string, int *p_index, int separator);#+ extern int subshell_exit_value;i%+ extern int subshell_exit_builtin;.&+ extern int subshell_skip_commands;+ extern int startup_state;b + #endif+ J /* The line number that the currently executing function starts on. */( static int function_line_number = 0; ***************M*** 129,134 ****--- 156,169 ---- F struct fd_bitmap *current_fds_to_close = (struct fd_bitmap *)NULL; + inta+ debug_getname (fd)+ int fd;+ {,+ char buffer[256]; B+ fprintf (stderr, "fd - %d: %s\n", fd, getname (fd, buffer));+ }m+ % #define FD_BITMAP_DEFAULT_SIZE 32rG /* Functions to allocate and deallocate the structures used to passuH information from the shell to its children about file descriptors****************** 178,183 ****--- 213,291 ----  } }0 + #if defined (USE_VMS) %+ static int delay_remove_size = 0;%'+ static int delay_remove_counts = 0; 0+ static char **delay_remove_filenames = NULL;;+ #define DELAY_REMOVE_DEFAULT_SIZE 5 /* at least size */n+ + static void++ add_delay_remove (const char *filename)p+ {d + int i;+ )+ if (delay_remove_filenames == NULL)m + {8+ delay_remove_size = DELAY_REMOVE_DEFAULT_SIZE;"+ delay_remove_counts = 0;E+ delay_remove_filenames = (char **) xmalloc (sizeof (char *)*!+ * delay_remove_size);g1+ for (i = 0; i < delay_remove_size; i++)&+ delay_remove_filenames[i] = NULL; + }r8+ else if (delay_remove_size >= delay_remove_counts) + {,!+ delay_remove_size *= 2;iN+ delay_remove_filenames = (char **) xrealloc (delay_remove_filenames,+ sizeof (char *)"+ * delay_remove_size);C+ for (i = delay_remove_counts; i < delay_remove_size; i++)o&+ delay_remove_filenames[i] = NULL; + },+ -+ for (i = 0; i < delay_remove_size; i++).+ if (delay_remove_filenames[i] == NULL) + {d7+ delay_remove_filenames[i] = savestring (filename);b+ delay_remove_counts++; + break;_ + }i+ }e+ + static void+ try_delay_remove (void).+ {M + int i;+ #+ if (delay_remove_counts == 0)*+ return;+ &+ /* search and delete if found */-+ for (i = 0; i < delay_remove_size; i++)z + {0+ if (delay_remove_filenames[i] == NULL)+ continue;+ 6+ if (remove (delay_remove_filenames[i]) == 0)+ {(+ free (delay_remove_filenames[i]);(+ delay_remove_filenames[i] = NULL;+ delay_remove_counts--;c+ } + }n+ "+ if (delay_remove_counts == 0<+ && delay_remove_size != DELAY_REMOVE_DEFAULT_SIZE) + {a!+ /* shrink array size */18+ delay_remove_size = DELAY_REMOVE_DEFAULT_SIZE;N+ delay_remove_filenames = (char **) xrealloc (delay_remove_filenames,+ sizeof (char *)"+ * delay_remove_size); + }w+ } + #endif+ F /* Execute the command passed in COMMAND. COMMAND is exactly whatK read_command () places into GLOBAL_COMMAND. See "command.h" for the ( details of the command structure.***************(*** 190,195 ****--- 298,306 ---- {* struct fd_bitmap *bitmap; int result;g+ #if defined (USE_VMS)t%+ int pipes = vmsutil_pipe_no ();f + #endif 6 current_fds_to_close = (struct fd_bitmap *)NULL;6 bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);*************** *** 205,210 ****--- 316,325 ----& #if defined (PROCESS_SUBSTITUTION) unlink_fifo_list ();% #endif /* PROCESS_SUBSTITUTION */2+ #if defined (USE_VMS)r!+ vmsutil_pipe_clean (pipes);h+ try_delay_remove (); + #endif  return (result); }(***************i*** 283,289 ****--- 398,408 ----8 fprintf (stderr, "pid %d open files:", getpid ());) for (i = 3; i < fd_table_size; i++)e  {g+ #if defined (USE_VMS)3+ if ((f = vmsfcntl (i, F_GETFD, 0)) != -1) + #else0 if ((f = fcntl (i, F_GETFD, 0)) != -1) + #endif; fprintf (stderr, " %d (%s)", i, f ? "close" : "open");  }n fprintf (stderr, "\n");_***************t*** 314,319 ****--- 433,442 ----  int invert, ignore_return;. REDIRECT *my_undo_list, *exec_undo_list; + #if defined (USE_VMS)1!+ if (subshell_skip_commands)5#+ return (EXECUTION_SUCCESS); + #endif- if (!command || breaking || continuing)y# return (EXECUTION_SUCCESS);/ ***************y*** 331,349 ****--- 454,502 ----H (pipe_out != NO_PIPE || pipe_in != NO_PIPE || asynchronous)))  { pid_t paren_pid;+ #if defined (USE_VMS)r+ COMMAND *old_command;t+ OLDENVBUF oldenvbuf; + #endif+ + #if defined (USE_VMS)(+ /* save arg list */+ old_command = command;e*+ command = copy_command (old_command); @+ /* save fd, jmp_buf, current directory, global variables *//+ vmsutil_save_all_environment (&oldenvbuf);d + #endifE /* Fork a subshell, turn off the subshell bit, turn off job B control and call execute_command () on the command again. */M paren_pid = make_child (savestring (make_command_string (command)),  asynchronous);e+ #if defined (USE_VMS) -+ /* force execute in parent shell */U+ if (paren_pid != 0)/ + #elsen if (paren_pid == 0) + #endif {6 int user_subshell, return_code, function_value;+ #if defined (USE_VMS)a+ char *old_trap_list[1];+ int old_sigmodes[1];: + #endif+ + #if defined (USE_VMS)0+ /* save signal */J+ old_trap_list[0] = trap_list[0] ? savestring (trap_list[0]) : NULL;6+ old_sigmodes[0] = vmsutil_get_signal_modes (0); + /* Cancel exit trap */f"+ restore_default_signal (0); + #elseL% /* Cancel traps, in trap.c. */# restore_original_signals ();* if (asynchronous)  setup_async_signals (); + #endif  #if defined (JOB_CONTROL). set_sigchld_handler ();***************L*** 427,433 ****--- 580,593 ---- if (command->redirects)  {B if (do_redirections (command->redirects, 1, 0, 0) != 0)+ #if defined (USE_VMS)v+ {P2+ vmsutil_wait_status = (EXECUTION_FAILURE);+ goto _exec1_return;s+ }c + #else_ exit (EXECUTION_FAILURE); + #endif 2 dispose_redirects (command->redirects);1 command->redirects = (REDIRECT *)NULL;***************u*** 448,458 ****--- 608,636 ---- if (return_catch_flag)*1 function_value = setjmp (return_catch);  + #if defined (USE_VMS)M7+ begin_unwind_frame ("subshell-execute-command");<0+ unwind_protect_int (subshell_exit_value);2+ unwind_protect_int (subshell_exit_builtin);3+ unwind_protect_int (subshell_skip_commands);*+ + subshell_exit_value = 0;value.Connection->first; REDIRECT *rp;+ #if defined (USE_VMS)a+ int ofd = -1; + #endif  if (!tc); break;r***************=*** 723,728 ****--- 937,950 ----  { REDIRECT *tr; + #if defined (USE_VMS)e + #if 0i+ /* save stdin */n#+ if ((ofd = dup (0)) < 0)v2+ internal_error ("cannot duplicate fd 0: %s",+ strerror (errno));+ #endif /* 0 */ + #endif1 rd.filename = make_word ("/dev/null");m= tr = make_redirection (0, r_inputa_direction, rd); $ tr->next = tc->redirects;***************n*** 744,749 ****--- 966,985 ----/ multiple times with the same command. */ REDIRECT *tr, *tl; + #if defined (USE_VMS) + #if 0t+ /* restore stdin */+ if (ofd >= 0)+ { + if (dup2 (ofd, 0) < 0)?+ internal_error ("cannot duplicate fd %d to fd 0: %s",n + ofd, strerror (errno));+ close (ofd);+ ofd = -1; + }_ + #endif m + #endif+  tr = tc->redirects;  do_ {l****************** 811,817 ****--- 1047,1057 ----1 cmd->value.Connection->connector == '|')  {5 /* Make a pipeline between the two commands. */_+ #if defined (USE_VMS) $+ if (vmsutil_pipe (fildes) < 0) + #elseZ if (pipe (fildes) < 0) + #endif  {< report_error ("pipe error: %s", strerror (errno)); #if defined (JOB_CONTROL)h***************l*** 852,858 ****--- 1092,1105 ----: (char *)fd_bitmap->bitmap, fds_to_close->size); @ /* And mark the pipe file descriptors to be closed. */+ #if defined (USE_VMS) + #if 0m+ /* close pipe in */N+ fd_bitmap->bitmap[fildes[0]] = 1;o+ #endif /* 0 */ + #else*++ fd_bitmap->bitmap[fildes[0]] = 1;0 + #endif B /* In case there are pipe or out-of-processes errors, we> want all these file descriptors to be closed when***************_*** 1053,1058 ****--- 1300,1309 ---- REAP (); QUIT;_ + #if defined (USE_VMS) %+ if (subshell_skip_commands)- + break;i + #endif if (breaking)i { breaking--; /***************I*** 1335,1340 ****--- 1586,1595 ---- REAP (); QUIT;_ + #if defined (USE_VMS) %+ if (subshell_skip_commands)* + break; + #endif if (breaking)- { breaking--;***************g*** 1496,1501 ****--- 1751,1760 ----? return_value = execute_command (while_command->test);( REAP (); + #if defined (USE_VMS)%+ if (subshell_skip_commands) + break;e + #endifE if (type == CMD_WHILE && return_value != EXECUTION_SUCCESS)  break;dE if (type == CMD_UNTIL && return_value == EXECUTION_SUCCESS)-*************** *** 1505,1510 ****--- 1764,1773 ----@ body_status = execute_command (while_command->action); QUIT;n + #if defined (USE_VMS)U%+ if (subshell_skip_commands)d + break;| + #endif if (breaking)T { breaking--;*************** *** 1534,1539 ****--- 1797,1806 ----3 if_command->test->flags |= CMD_IGNORE_RETURN;r8 return_value = execute_command (if_command->test); + #if defined (USE_VMS)M!+ if (subshell_skip_commands)V$+ return (EXECUTION_SUCCESS); + #endif, if (return_value == EXECUTION_SUCCESS)  {c QUIT;m*************** *** 1576,1581 ****--- 1843,1853 ----# char *command_line, *lastarg;e$ int first_word_quoted, result;' pid_t old_last_command_subst_pid;*+ #if defined (USE_VMS)t + #if 0 #+ int ofds[3] = { -1, -1, -1 }; + #endif /* 0 */ + #endif ! result = EXECUTION_SUCCESS;a ***************e*** 1586,1593 ****--- 1858,1870 ----E /* Remember what this command line looks like at invocation. */i command_string_index = 0;(, print_simple_command (simple_command);+ #if defined (USE_VMS)0+ /* Expect to call function 'savestring' */)+ command_line = the_printed_command; + #elseoG command_line = (char *)alloca (1 + strlen (the_printed_command)); 1 strcpy (command_line, the_printed_command); + #endif  first_word_quoted = H simple_command->words ? simple_command->words->word->quoted : 0;***************/*** 1730,1735 ****--- 2007,2018 ----I If so, and we have pipes, then fork a subshell in here. Else, justr do the command. */ + #if defined (USE_VMS) + #if 0a+ save_std_fds (ofds);+ #endif /* 0 */ + #endif+  if (func)l  builtin = (Function *)NULL; else****************** 1742,1748 ****--- 2025,2035 ---- {B if ((pipe_in != NO_PIPE) || (pipe_out != NO_PIPE) || async)  {+ #if defined (USE_VMS)uB+ if (make_child (savestring (command_line), async) != 0) + #elseB if (make_child (savestring (command_line), async) == 0) + #endif {c& /* Cancel traps, in trap.c. */$ restore_original_signals ();****************** 1750,1759 ****--- 2037,2057 ---- if (async)! setup_async_signals ();s + #if defined (USE_VMS) 2+ expand_words_for_internal_command (words); + #endif, execute_subshell_builtin_or_function; (words, simple_command->redirects, builtin, func,t2 pipe_in, pipe_out, async, fds_to_close," simple_command->flags);+ #if defined (USE_VMS)b!+ /* execute parent side */b(+ close_pipes (pipe_in, pipe_out);?+ #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD);+ unlink_fifo_list (); + #endif+ goto return_result; + #endif }r elseO {s***************i*** 1766,1782 ****--- 2064,2112 ----  }  else  {+ #if defined (USE_VMS)v + #if 0 ?+ if (subshell_environment || builtin != exec_builtin) + save_std_fds (ofds);+ #endif /* 0 */ + #endif+ #if defined (USE_VMS)e5+ expand_words_for_internal_command (words); + #endif/ result = execute_builtin_or_function[E (words, builtin, func, simple_command->redirects, fds_to_close,  simple_command->flags);+ #if defined (USE_VMS) + #if 0e"+ restore_std_fds (ofds);+ #endif /* 0 */ + #endif  goto return_result;  } } + #if defined (USE_VMS) + #if 00+ save_std_fds (ofds);+ #endif /* 0 */ + #endifO execute_disk_command (words, simple_command->redirects, command_line,r2 pipe_in, pipe_out, async, fds_to_close,2 (simple_command->flags & CMD_NO_FORK));+ #if defined (USE_VMS)m + #if 0 !+ restore_std_fds (ofds);+ #endif /* 0 */+ /+ /* sh -c "foo": Return result code */e!+ if (startup_state == 2){+ {$+ result = vmsutil_wait_status;/+ if ((result & 0x0000ff00) == 0x0000ff00) + result &= 0x000000ff;+ } + #endif  goto return_result;i  }E******************* 1786,1805 ****--- 2116,2154 ----F care of it. Just fork, do piping and redirections, and exit. */7 if (make_child (savestring (""), async) == 0)r {+ #if !(defined (USE_VMS))% /* Cancel traps, in trap.c. */7# restore_original_signals ();i + #endif % do_piping (pipe_in, pipe_out);m  subshell_environment = 1; E if (do_redirections (simple_command->redirects, 1, 0, 0) == 0)P+ #if defined (USE_VMS) + {5+ vmsutil_wait_status = (EXECUTION_SUCCESS);O!+ goto null_return_exit;0 + } + #else-" exit (EXECUTION_SUCCESS); + #endif  elsen+ #if defined (USE_VMS) + {5+ vmsutil_wait_status = (EXECUTION_FAILURE);f!+ goto null_return_exit; + } + #else*" exit (EXECUTION_FAILURE); + #endif } else {+ #if defined (USE_VMS) + null_return_exit: + #endif' close_pipes (pipe_in, pipe_out);u? #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) unlink_fifo_list ();****************** 1826,1831 ****--- 2175,2186 ----  }l  return_result:r+ #if defined (USE_VMS)e + #if 0 + restore_std_fds (ofds);i+ #endif /* 0 */ + #endif+  bind_lastarg (lastarg);J /* The unwind-protect frame is set up only if WORDS is not empty. */ if (words)****************** 1878,1883 ****--- 2233,2244 ---- * result = ((*builtin) (words->next)); + #if defined (USE_VMS)n!+ /* check subshell return */oA+ if (builtin == exit_builtin && result == EXECUTION_SUCCESS);)+ result = last_command_exit_value;m + #endif+ 5 if (subshell == 0 && builtin == source_builtin)  {*! dispose_builtin_env ();-****************** 1999,2004 ****--- 2360,2373 ----( struct fd_bitmap *fds_to_close; int flags;m {*+ #if defined (USE_VMS)S+ OLDENVBUF oldenvbuf; + #endif+ + #if defined (USE_VMS) A+ /* save fd, jmp_buf, current directory, global variables */%0+ vmsutil_save_all_environment (&oldenvbuf); + #endif@ /* A subshell is neither a login shell nor interactive. */$ login_shell = interactive = 0; *************** *** 2029,2035 ****--- 2398,2411 ----' close_fd_bitmap (fds_to_close); 4 if (do_redirections (redirects, 1, 0, 0) != 0)+ #if defined (USE_VMS)o + {f4+ vmsutil_wait_status = (EXECUTION_FAILURE);+ goto return_exit; + } + #elset! exit (EXECUTION_FAILURE);r + #endif  if (builtin)  {p***************h*** 2039,2044 ****--- 2415,2433 ----* so we don't go back up to main(). */& result = setjmp (top_level); + #if defined (USE_VMS)l!+ if (result == EXITPROG) 5+ vmsutil_wait_status = (last_command_exit_value);n+ else if (result)/+ vmsutil_wait_status = (EXECUTION_FAILURE); + elseH+ vmsutil_wait_status = (execute_builtin (builtin, words, flags, 1)); + }s + else + {e_+ vmsutil_wait_status = (execute_function (var, words, flags, fds_to_close, async, 1));* + }7 + #else-! if (result == EXITPROG)c$ exit (last_command_exit_value); else if (result)****************** 2050,2055 ****--- 2439,2453 ----  {N exit (execute_function (var, words, flags, fds_to_close, async, 1));  }k + #endif+ #if defined (USE_VMS)r+ return_exit:D+ /* restore fd, jmp_buf, current directory, global variables */3+ vmsutil_restore_all_environment (&oldenvbuf);w+ + /* return in subshell */ + return;i + #endif }U N /* Execute a builtin or function in the current shell context. If BUILTIN*************** *** 2167,2172 ****--- 2565,2574 ----* char *hashed_file, *command, **args; int pid, temp_path;D SHELL_VAR *path;+ #if defined (USE_VMS)a#+ int ofds[3] = { -1, -1, -1 }; + char *fixp; + #endif # pathname = words->word->word;E" #if defined (RESTRICTED_SHELL)*************** *** 2203,2209 ****--- 2605,2619 ----  {* int st;  + #if defined (USE_VMS)-1+ /* for adding extention (dot + 3ext) */ <+ fixp = xmalloc (1 + strlen (hashed_file) + 1 + 3);%+ strcpy (fixp, hashed_file); "+ st = file_status (fixp);+ free (fixp); + #elsee) st = file_status (hashed_file);S + #endif4 if ((st ^ (FS_EXISTS | FS_EXECABLE)) != 0) {) remove_hashed_filename (pathname);o***************o*** 2216,2222 ****--- 2626,2644 ----+ else if (absolute_program (pathname))L /* A command containing a slash is not looked up in PATH or saved in the hash table. */c+ #if defined (USE_VMS) + {e+ /* search suffix */t=+ fixp = vmsutil_expand_path (savestring (pathname));_D+ command = find_user_command_internal (fixp, FS_EXEC_ONLY);+ if (command == NULL)+ command = fixp;+ else+ free (fixp);7 + }* + #else7( command = savestring (pathname); + #endif  else  {s1 command = find_user_command (pathname);e****************** 2234,2247 ****--- 2656,2688 ----P /* If we can get away without forking and there are no pipes to deal with,A don't bother to fork, just directly exec the command. */> if (nofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE)+ #if defined (USE_VMS)s"+ pid = vmsutil_current_pid; + #else pid = 0; + #endif  else+ #if defined (USE_VMS) + { &+ vmsutil_save_std_fds (ofds);>+ pid = make_child (savestring (command_line), async); + }r + #else< pid = make_child (savestring (command_line), async); + #endif + #if defined (USE_VMS) + if (pid != 0) + #else_ if (pid == 0) + #endif  {  int old_interactive;+ #if defined (USE_VMS)e>+ int old_subshell_environment = subshell_environment; + #endif + #if !(defined (USE_VMS))( /* Cancel traps, in trap.c. */& restore_original_signals (); ***************U*** 2250,2255 ****--- 2691,2697 ----) in asynchronous children. */ if (async) setup_async_signals (); + #endif ( do_piping (pipe_in, pipe_out); ****************** 2281,2307 ****--- 2723,2796 ----$ result of redirections. */ unlink_fifo_list ();-% #endif /* PROCESS_SUBSTITUTION */+ #if defined (USE_VMS)1+ vmsutil_wait_status = (EXECUTION_FAILURE);b+ goto _exec_return; + #elsed  exit (EXECUTION_FAILURE); + #endif }  if (async)# interactive = old_interactive;( + #if defined (USE_VMS)r+ if (!command)r+ {?+ vmsutil_wait_status = vms_spawn (words, pathname, args);o4+ if (vmsutil_wait_status == EXECUTION_SUCCESS)+ goto _exec_return;.+ if (vmsutil_wait_status != CLI$_IVVERB) + {1+ vmsutil_wait_status = (EX_USAGE << 8); + goto _exec_return;e + }+ } + #endif+  if (!command)e {7 report_error ("%s: command not found", args[0]);s+ #if defined (USE_VMS)o0+ vmsutil_wait_status = (EX_NOTFOUND << 8);+ goto _exec_return;( + #elseaD exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */ + #endif } + #if defined (USE_VMS)W+ vmsutil_wait_status = shell_execve_dos (words, command, args, export_env, 1);{+ _exec_return:s$+ dispose_word_array (args);+ )+ vmsutil_restore_std_fds (ofds);r+ + /* for parent shell */)+ if (pid == vmsutil_current_pid) + goto disk_command_nofork;+ *+ /* restore parent environment */:+ subshell_environment = old_subshell_environment;+ #+ goto disk_command_parent;, + #else0: exit (shell_execve (command, args, export_env)); + #endif  }  else  {i+ #if defined (USE_VMS) + disk_command_parent: + #endifB /* Make sure that the pipes are closed in the parent. */* close_pipes (pipe_in, pipe_out);? #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)t unlink_fifo_list ();  #endif+ #if defined (USE_VMS)t+ disk_command_nofork: + #endif FREE (command);  } }s*************** *** 2315,2359 ****--- 2804,2914 ---- K The word immediately following the #! is the interpreter to execute.: A single argument to the interpreter is allowed. */+ #if defined (USE_VMS) + static intH+ execute_shell_script (sample, sample_len, words, command, args, env)+ unsigned char *sample;e+ int sample_len;+ WORD_LIST *words;+ char *command;+ char **args, **env; + #else* static intA execute_shell_script (sample, sample_len, command, args, env)E unsigned char *sample;_ int sample_len; char *command; char **args, **env; + #endif {u register int i;s  char *execname, *firstarg;' int start, size_increment, larry;+ #if defined (USE_VMS) + WORD_LIST *newwords;+ char *fixp;)+ char **newargs;+ int status;E + #endif 5 /* Find the name of the interpreter to exec. */l@ for (i = 2; whitespace (sample[i]) && i < sample_len; i++)  ;e + #if defined (USE_VMS)u+ /* support CR/LF */o+ for (start = i; 7+ !whitespace (sample[i]) && sample[i] != '\r'2+ && sample[i] != '\n' && i < sample_len;+ i++)a + #elsel for (start = i;sJ !whitespace (sample[i]) && sample[i] != '\n' && i < sample_len; i++) + #endif  ; + execname = xmalloc (1 + (i - start));l? strncpy (execname, (char *) (sample + start), i - start);! execname[i - start] = '\0';n+ #if defined (USE_VMS)t+ /* search suffix */h,+ fixp = vmsutil_expand_path (execname);A+ execname = find_user_command_internal (fixp, FS_EXEC_ONLY);t+ if (execname == NULL)+ execname = fixp; + else+ free (fixp);+ /+ /* research without absolute pathname? */sS+ if (access (execname, X_OK) != 0 && (fixp = strrchr (execname, '/')) != NULL) + {(+ fixp++;r"+ strcpy (execname, fixp);1+ fixp = xmalloc (strlen (execname) + 5); "+ strcpy (fixp, execname);+ free (execname);E+ execname = find_user_command_internal (fixp, FS_EXEC_ONLY);U + } + #endif size_increment = 1;v % /* Now the argument, if any. */) firstarg = (char *)NULL;+ #if defined (USE_VMS)(+ /* support CR/LF */ + for (start = i;w6+ whitespace (sample[i]) && sample[i] != '\r'2+ && sample[i] != '\n' && i < sample_len;+ i++) + #elsef for (start = i;aI whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;t i++) + #endif  ;x J /* If there is more text on the line, then it is an argument for the interpreter. */+ #if defined (USE_VMS)c+ /* support CR/LF */l-+ if (i < sample_len && sample[i] != '\r' :+ && sample[i] != '\n' && !whitespace (sample[i])) + #elsefI if (i < sample_len && sample[i] != '\n' && !whitespace (sample[i]))l + #endif  {u+ #if defined (USE_VMS) + /* support CR/LF */+ for (start = i;4+ !whitespace (sample[i]) && sample[i] != '\r'/+ && sample[i] != '\n' && i < sample_len; + i++) + #else5 for (start = i;hG !whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;p  i++) + #endif ;/ firstarg = xmalloc (1 + (i - start));*B strncpy (firstarg, (char *)(sample + start), i - start);***************C*** 2364,2373 ****--- 2919,2941 ---- 0 larry = array_len (args) + size_increment; + #if defined (USE_VMS)EA+ newargs = (char **)xmalloc ((1 + larry) * sizeof (char *)); (+ newwords = copy_word_list (words);+ if (firstarg) C+ newwords = make_word_list (make_word (firstarg), newwords); A+ newwords = make_word_list (make_word (execname), newwords);f+ 3+ for (i = larry - 1; i >= size_increment; i--)C.+ newargs[i] = args[i - size_increment];+ + args = newargs;* + #else*M args = (char **)xrealloc ((char *)args, (1 + larry) * sizeof (char *));m ! for (i = larry - 1; i; i--)l+ args[i] = args[i - size_increment]; + #endif  args[0] = execname;U if (firstarg)*************** *** 2380,2401 **** ! args[larry] = (char *)NULL;a 2 return (shell_execve (execname, args, env)); }  H /* Call execve (), handling interpreting shell scripts, and handling exec failures. */ int*% shell_execve (command, args, env)i char *command;f char **args, **env; {o3 #if defined (isc386) && defined (_POSIX_SOURCE)*6 __setostype (0); /* Turn on USGr3 semantics. */" execve (command, args, env);? __setostype (1); /* Turn the POSIX semantics back on. */f  #elsei"! execve (command, args, env);+ #endif /* !(isc386 && _POSIX_SOURCE) */= C /* If we get to this point, then start checking out the file.--- 2948,3081 ---- ! args[larry] = (char *)NULL;e + #if defined (USE_VMS) C+ status = shell_execve_dos (newwords, execname, args, env, 1);t+ dispose_words (newwords); + free (execname);+ free (newargs);a+ return status; + #else2 return (shell_execve (execname, args, env)); + #endif }  + #if defined (USE_VMS) D+ typedef struct dsc {unsigned short len, mbz; char *adr; } Descr;+ + int $+ vms_spawn (words, command, args)+ WORD_LIST *words;+ char *command;e+ char **args; + {e+ Descr cmd;+ int status, vms_status;l + int i;+ int len = 1;+ + for (i=0; args[i]; i++)1)+ len = len + strlen (args[i]) + 1;i+ + { .+ char *allargs = (char*) xmalloc (len);+ #+ strcpy (allargs, args [0]);_+ strcat (allargs, " ");+ + for (i=1; args[i]; i++)7 + {&+ strcat (allargs, args[i]);"+ strcat (allargs, " "); + }_+ cmd.adr = allargs;+ cmd.len = len;+ cmd.mbz = 0;+ 8+ vms_status = lib$spawn (&cmd,0,0,0,0,0,&status);+ xfree (allargs);+ "+ if ((vms_status & 1) != 1)+ return (vms_status);+ + vms_status = status;"+ if ((vms_status & 1) != 1)+ return (vms_status);+ #+ return (EXECUTION_SUCCESS);g+ } + }v + #endif+ H /* Call execve (), handling interpreting shell scripts, and handling exec failures. */+ #if defined (USE_VMS)s+ int_%+ shell_execve (command, args, env)g+ char *command; + char **args, **env;+ { I+ return shell_execve_dos ((WORD_LIST *)NULL, command, args, env, 0);r+ }s+ + /*D+ * flag: 0 = execve, 1 = spawnve, 2 = spawnve from exec builtin,+ */e+ intn6+ shell_execve_dos (words, command, args, env, flag)+ WORD_LIST *words;+ char *command; + char **args, **env;+ int flag; + #else  intc% shell_execve (command, args, env)v char *command;s char **args, **env; + #endif { 3 #if defined (isc386) && defined (_POSIX_SOURCE) 6 __setostype (0); /* Turn on USGr3 semantics. */" execve (command, args, env);? __setostype (1); /* Turn the POSIX semantics back on. */  #elsel! #if defined (USE_VMS)_! int status = -1;! char **newargs;_! #if defined (USE_VMS) ! int real_pid;e ! #endif! ! if (flag) ! { ! #if defined (USE_VMS) ! #if 0 ! {V! char buffer[256];:! fprintf (stderr, "stdin: %s\n", getname (0, buffer));;! fprintf (stderr, "stdout: %s\n", getname (1, buffer));i;! fprintf (stderr, "stderr: %s\n", getname (2, buffer));H ! } ! #endif(! if ((real_pid = vfork ()) < 0)! return (real_pid);k!! else if (real_pid == 0) ! {7! if ((status = execve (command, args, env)) >= 0)*! exit (status);8! }! else! {&! waitpid (real_pid, &status, 0);! return (status);! } ! #elseuC! if ((status = spawnve (P_WAIT, command, args, env)) >= 0)! return status;c ! #endif ! }e ! else ! #endif$! execve (command, args, env);+ #endif /* !(isc386 && _POSIX_SOURCE) */  C /* If we get to this point, then start checking out the file.;***************t*** 2421,2427 ****--- 3101,3111 ----H if the first line (or up to 30 characters) are in the ASCII set.2 Execute the contents as shell commands. */' int larray = array_len (args) + 1;u+ #if defined (USE_VMS)+ int i, should_exec = 1; + #else  int i, should_exec = 0; + #endif  {) int fd = open (command, O_RDONLY);******************** 2443,2450 ****--- 3127,3139 ---- characters. */  F if (sample_len > 0 && sample[0] == '#' && sample[1] == '!')+ #if defined (USE_VMS)"+ return (execute_shell_script8+ (sample, sample_len, words, command, args, env)); + #else " return (execute_shell_script1 (sample, sample_len, command, args, env));s + #endif) else if ((sample_len != -1) &&a4 check_binary_file (sample, sample_len)) {n***************;*** 2453,2458 ****--- 3142,3149 ---- }  } }+ + #if !(defined (USE_VMS)) #if defined (JOB_CONTROL)tA /* Forget about the way that job control was working. We arei in a subshell. */a*************** *** 2467,2478 ****--- 3158,3179 ---- set_sigchld_handler (); #endif /* JOB_CONTROL */ set_sigint_handler ();U + #endif @ /* Insert the name of this shell into the argument list. */+ #if defined (USE_VMS)nA+ newargs = (char **)xmalloc ((1 + larray) * sizeof (char *)); + !+ for (i = larray - 1; i; i--) + newargs[i] = args[i - 1];+ + args = newargs; + #elseaM args = (char **)xrealloc ((char *)args, (1 + larray) * sizeof (char *));r ! for (i = larray - 1; i; i--)_ args[i] = args[i - 1];_ + #endif  args[0] = shell_name; args[1] = command;***************g*** 2490,2504 ****--- 3191,3242 ----( execve (shell_name, args, env);A __setostype (1); /* Turn the POSIX semantics back on. */  #else + #if defined (USE_VMS) + if (flag) + {+ #if defined (USE_VMS) + #if 0f+ {o+ char buffer[256];w=+ fprintf (stderr, "stdin: %s\n", getname (0, buffer));>+ fprintf (stderr, "stdout: %s\n", getname (1, buffer));>+ fprintf (stderr, "stderr: %s\n", getname (2, buffer));+ }r + #endif$+ if ((real_pid = vfork ()) < 0)+ return (real_pid);+ else if (real_pid == 0)' + { =+ if ((status = execve (shell_name, args, env)) >= 0)f+ exit (status); + } + else + {()+ waitpid (real_pid, &status, 0);i+ return (status); + }o + #endif + } + else + #endif( execve (shell_name, args, env);( #endif /* isc386 && _POSIX_SOURCE */ !+ #if 0 /* defined (USE_VMS) */ C+ /* ??? Copy stuff from Gnu make to execute command file */\ + #endif+ 3 /* Oh, no! We couldn't even exec this! */sH if ((stat (args[0], &finfo) == 0) && (S_ISDIR (finfo.st_mode)))8 report_error ("%s: is a directory", args[0]);  else  file_error (args[0]); + #if defined (USE_VMS)r+ free (newargs);+ if (flag == 2)a+ return -1;( + #endif$ return (EXECUTION_FAILURE); }  elses***************a*** 2551,2556 ****--- 3289,3298 ----" pipe_in, strerror (errno)); if (pipe_in > 0) close (pipe_in);+ #if defined (USE_VMS)l"+ /* reset file pointer */!+ lseek (0, 0, SEEK_SET);e + #endif  }  if (pipe_out != NO_PIPE)  {=***************(*** 2831,2836 ****--- 3573,3581 ---- struct stat finfo;r int stat_result;  + #if defined (USE_VMS)]?+ redirectee_word = vmsutil_expand_path (redirectee_word);a + #endif4 stat_result = stat (redirectee_word, &finfo); ; if ((stat_result == 0) && (S_ISREG (finfo.st_mode))) *************** *** 2844,2850 ****--- 3589,3600 ---- if (stat_result != 0)# redirect->flags |= O_EXCL;  + #if defined (USE_VMS)aD+ fd = open (redirectee_word, redirect->flags | O_APPEND, 0666,F+ "rfm=stmlf", "ctx=rec", "rat=none", "shr=del,get,put,upd"); + #else : fd = open (redirectee_word, redirect->flags, 0666); + #endif ) if ((fd < 0) && (errno == EEXIST))a  {***************x*** 2854,2860 **** } else {:! fd = open (redirectee_word, redirect->flags, 0666);  #if defined (AFS_CREATE_BUG)) if ((fd < 0) && (errno == EACCES))rI fd = open (redirectee_word, (redirect->flags & ~O_CREAT), 0666);l--- 3604,3618 ---- } else {! #if defined (USE_VMS) ?! redirectee_word = vmsutil_expand_path (redirectee_word);a ! #endif! #if defined (USE_VMS)x9! fd = open (redirectee_word, redirect->flags, 0666, F! "rfm=stmlf", "ctx=rec", "rat=none", "shr=del,get,put,upd"); ! #else ;! fd = open (redirectee_word, redirect->flags, 0666); ) ! #endif  #if defined (AFS_CREATE_BUG)) if ((fd < 0) && (errno == EACCES))I fd = open (redirectee_word, (redirect->flags & ~O_CREAT), 0666); ***************o*** 2869,2875 ****--- 3627,3637 ---- { if (remembering) D /* Only setup to undo it if the thing to undo is active. */+ #if defined (USE_VMS)M+ if ((fd != redirector) && (vmsfcntl (redirector, F_GETFD, 0) != -1)) + #else J if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1)) + #endif* add_undo_redirect (redirector);  else.0 add_undo_close_redirect (redirector);***************s*** 2934,2944 ****--- 3696,3725 ----6 the new input. Place it in a temporary file. */ if (redirectee)s {+ #if defined (USE_VMS) + char *filename;+ char *tname;+ char *tmpdir; + #elseC char filename[40]; + #endif pid_t pid = getpid ();l 1 /* Make the filename for the temp file. */ + #if defined (USE_VMS)e"+ tmpdir = getenv ("TMPDIR");+ if (tmpdir == NULL)+ tmpdir = "/tmp";+ @+ tname = xmalloc (strlen (tmpdir) + sizeof ("/shXXXXXX"));<+ sprintf (tname, "%s/sh%6.6d", tmpdir, pid % 1000000);++ tname = vmsutil_expand_path (tname);w.+ filename = alloca (strlen (tname) + 1); + strcpy (filename, tname);+ free (tname); + #elseI. sprintf (filename, "/tmp/t%d-sh", pid); + #endif @ fd = open (filename, O_TRUNC | O_WRONLY | O_CREAT, 0666); if (fd < 0)***************d*** 3014,3029 ****--- 3795,3824 ----  } i  close (fd);%+ #if 0 /* ??? defined (USE_VMS) */ $+ if (errno && errno != ENOTTY)+ return (errno); + else + errno = 0;* + #elseO if (errno)o return (errno); + #endif I /* Make the document really temporary. Also make it the input. */S, fd = open (filename, O_RDONLY, 0666); :+ #if defined (USE_VMS) /* otherwise file is unlinked */+ if (fd < 0) + #elser+ if (unlink (filename) < 0 || fd < 0)g + #endif  { if (fd >= 0)u close (fd);+ #if defined (USE_VMS)r+ remove (filename);u + #endif return (errno);  } ****************** 3031,3037 ****--- 3826,3836 ----  { if (remembering)tA /* Only setup to undo it if the thing to undo is active. */+ #if defined (USE_VMS) J+ if ((fd != redirector) && (vmsfcntl (redirector, F_GETFD, 0) != -1)) + #elseuG if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1)) + #endif' add_undo_redirect (redirector);e  else- add_undo_close_redirect (redirector);d***************P*** 3042,3047 ****--- 3841,3849 ----) if (dup2 (fd, redirector) < 0)i {* close (fd); + #if defined (USE_VMS)3+ remove (filename); + #endif return (errno);i }I ***************h*** 3058,3063 ****--- 3860,3871 ----  #elsea close (fd);  #endif+ #if defined (USE_VMS) + #if 0 "+ if (remove (filename) != 0) + #endif%+ add_delay_remove (filename); + #endif } break; ***************5*** 3067,3073 ****--- 3875,3885 ---- { if (remembering)mD /* Only setup to undo it if the thing to undo is active. */+ #if defined (USE_VMS)x5+ if (vmsfcntl (redirector, F_GETFD, 0) != -1)c + #elses2 if (fcntl (redirector, F_GETFD, 0) != -1) + #endif* add_undo_redirect (redirector);  else0 add_undo_close_redirect (redirector);***************i*** 3091,3097 ****--- 3903,3913 ----9 unless closed by something like `exec 2<&-'. */ B /* if ((already_set || set_unconditionally) && (ok_to_set)) set_it () */+ #if defined (USE_VMS)tD+ if (((vmsfcntl (redir_fd, F_GETFD, 0) == 1) || set_clexec) && + #else*A if (((fcntl (redir_fd, F_GETFD, 0) == 1) || set_clexec) &&g + #endif (redirector > 2)) ( SET_CLOSE_ON_EXEC (redirector); }***************e*** 3100,3106 ****--- 3916,3927 ---- case r_close_this: if (for_real)* {+ char buffer[256];+ #if defined (USE_VMS)(D+ if (remembering && (vmsfcntl (redirector, F_GETFD, 0) != -1)) + #elseaA if (remembering && (fcntl (redirector, F_GETFD, 0) != -1)) + #endif( add_undo_redirect (redirector);  #if defined (BUFFERED_INPUT)***************f*** 3129,3135 ****--- 3950,3960 ---- int new_fd, clexec_flag;& REDIRECT *new_redirect, *closer; + #if defined (USE_VMS)n+ new_fd = dup (fd); + #elsee2 new_fd = fcntl (fd, F_DUPFD, SHELL_FD_BASE); + #endif  if (new_fd < 0)  {)*************** *** 3139,3146 ****--- 3964,3976 ----  else  {5# REDIRECT *dummy_redirect;:+ char buffer[256]; + #if defined (USE_VMS)t2+ clexec_flag = vmsfcntl (fd, F_GETFD, 0); + #elser/ clexec_flag = fcntl (fd, F_GETFD, 0);d + #endif  rd.dest = 0L;? closer = make_redirection (new_fd, r_close_this, rd); ***************s*** 3228,3237 ****--- 4058,4095 ---- {  struct stat finfo; static int user_id = -1;+ #if defined (USE_VMS)i+ char *ext, *newname;+ int len; + #endif 6 /* Determine whether this file exists or not. */+ #if defined (USE_VMS),+ len = strlen (name);+ if (len + 5 > PATH_MAX) + return 0;S+ "+ newname = xmalloc (len + 5);+ strcpy (newname, name);i+ + ext = newname + len;+ + /* skip a directory */C+ while (stat (newname, &finfo) < 0 || S_ISDIR (finfo.st_mode)). + {+ #if defined (USE_VMS)s<+ if (!vmsutil_add_executable_suffix (newname, ext)) + #endif+ {+ free (newname);+ return 0; /* failure */+ } + } + free (newname);r + #else " if (stat (name, &finfo) < 0) return (0); + #endif G /* If the file is a directory, then it is not "executable" in thet sense of the shell. */i*************** *** 3478,3484 ****--- 4336,4347 ---- int path_len;s  path_len = strlen (path); + #if defined (USE_VMS)-+ /* for adding extention (dot + 3ext) */ <+ full_path = xmalloc (2 + path_len + name_len + 1 + 3); + #else4 full_path = xmalloc (2 + path_len + name_len); + #endif strcpy (full_path, path);c  full_path[path_len] = '/';. strcpy (full_path + path_len + 1, name);***************_*** 3520,3526 ****--- 4383,4394 ---- " if (absolute_program (name))  {*+ #if defined (USE_VMS)1+ /* for adding extention (dot + 3ext) */5+ full_path = xmalloc (1 + name_len + 1 + 3);i + #elseS- full_path = xmalloc (1 + name_len);- + #endif# strcpy (full_path, name);  + status = file_status (full_path); *************** *** 3661,3666 ****--- 4529,4537 ----* value = xmalloc (1 + i - start);5 strncpy (value, string + start, i - start);# value [i - start] = '\0'; + #if defined (USE_VMS)p.+ value = vmsutil_expand_path (value); + #endif  return (value);d  }r****************** 3696,3698 ****--- 4567,4724 ----  }O return (0); }4+ + #if defined (USE_VMS)e+ static int%+ check_batch_file (char *filename)_+ {v+ int len;+ (+ if ((len = strlen (filename)) > 4)&+ if ((filename[len - 4] == '.')>+ && (filename[len - 3] == 'C' || filename[len - 3] == 'c')>+ && (filename[len - 2] == 'O' || filename[len - 2] == 'o')?+ && (filename[len - 1] == 'M' || filename[len - 1] == 'm'))+ return 1;C+ + return 0;(+ } + + static void8+ expand_words_for_internal_command (WORD_LIST *words)+ {,+ char *p;+ 0+ if (!vmsutil_path_expand || words == NULL)+ return;i+ 2+ words = words->next; /* skip command name */+ while (words)i + { + p = words->word->word;%+ if (words->word->expansion)i+ {+ /* nothing */+ } + words->word->word = p;+ words = words->next; + })+ }e+ + static voiddX+ expand_arguments_for_external_command (WORD_LIST *words, char **args, char **except)+ {*+ char *p, *sysroot = NULL;*+ int i, sysroot_len = -1;+ Q+ if (!vmsutil_path_expand || words == NULL || args == NULL || *args == NULL)i+ return;S+ "+ if (vmsutil_sysroot_len > 0) + { 1+ sysroot = get_string_value ("SYSROOT");4)+ sysroot_len = strlen (sysroot); + }+ %+ args++; /* skip command name */.+ words = words->next;!+ while ((p = *args) != NULL)I + { !+ /* may skip argument */i+ if (except != NULL)e+ {6+ if (strnicmp (p, "--", sizeof ("--") - 1) == 0) + {0+ except = NULL; /* terminate switch */+ args++;+ goto done;f + }+ *+ for (i = 1; except[i] != NULL; i++) + {@+ if (strnicmp (p, except[i], strlen (except[i])) == 0)+ {p+ skip_args:+ args++; <+ if (*args != NULL) /* skip only complete argument */ + { + words = words->next;+ args++; + } + goto done;+ }d + }+ }+ .+ /* expands only non-quoted string */%+ if (words->word->expansion) + {A+ /* insterts SYSROOT(may have double-slashed drive name) */r)+ if (sysroot_len > 0 && p[0] == '/'e>+ && (p[1] == '\0' || (p[1] != '/' && p[2] != '\0'))) + {:+ p = xrealloc (p, strlen (p) + sysroot_len + 1);8+ memmove (p + sysroot_len, p, strlen (p) + 1);,+ memcpy (p, sysroot, sysroot_len); + }+ .+ /* expands double-slashed drive name */6+ if (p[0] == '/' && p[1] == '/' && isalpha(p[2]),+ && (p[3] == '/' || p[3] == '\0')) + {+ p[0] = p[2];+ p[1] = ':';!+ strcpy (p + 2, p + 3);-++ p = xrealloc (p, strlen(p) + 1); + }+ }+ #+ /* stores and increses */*+ *args++ = p; + done:f+ words = words->next; + }o+ }T+ + static voidsI+ maybe_expand_arguments (WORD_LIST *words, char *command, char **args)+ {e8+ static char *except_sed[] = { "sed", "-e", NULL };:+ static char *except_gsed[] = { "gsed", "-e", NULL };$+ static char **except_array[] = + {-+ except_sed, + except_gsed,+ NULL + };5+ static char *shells[] = { "bash", "sh", NULL };e&+ char **except = NULL, *fixp, *p;+ int i, need_expand = 1;*+ B+ if (!vmsutil_path_expand || words == NULL || command == NULL++ || args == NULL || *args == NULL) + return; + "+ fixp = savestring (command);+ vmsutil_toslash (fixp);l,+ if ((p = strrchr (fixp, '/')) == NULL)+ p = fixp - 1;* + p++;)+ for (i = 0; shells[i] != NULL; i++)=+ if (strnicmp (p, shells[i], strlen (shells[i])) == 0)t + {n+ need_expand = 0;i + break;E + } + if (need_expand) + {D3+ for (i = 0; except_array[i] != NULL; i++)tL+ if (strnicmp (p, except_array[i][0], strlen (except_array[i][0])) == 0) + except = except_array[i]; + }e+ free (fixp);+ + if (need_expand)D+ expand_arguments_for_external_command (words, args, except);+ } + #endif=diff -r -c bash-1_14_7/execute_cmd.h bash1147/execute_cmd.h_8*** bash-1_14_7/execute_cmd.h Wed Mar 10 09:43:46 19995--- bash1147/execute_cmd.h Wed Mar 10 09:44:54 1999e***************e*** 44,47 ****--- 44,53 ----, extern void close_all_files __P((void));  #endif + #if defined (USE_VMS)SN+ extern int shell_execve_dos (WORD_LIST *words, char *command, char **args,"+ char **env, int flag);J+ extern char *extract_unit (char *string, int *p_index, int separator); + #endif+  #endif /* _EXECUTE_CMD_H_ */7diff -r -c bash-1_14_7/filecntl.h bash1147/filecntl.h5*** bash-1_14_7/filecntl.h Wed Mar 10 09:43:46 199902--- bash1147/filecntl.h Wed Mar 10 09:44:54 1999****************** 30,36 ****--- 30,61 ----  #define FD_NCLOEXEC 0 + #if defined (USE_VMS)n+ #define F_DUPFD 0+ #define F_GETFD 1i+ #define F_SETFD 2+ #define F_GETFL 3n+ #define F_SETFL 4d+ #define F_GETLK 7e+ #define F_SETLK 8F+ #define F_SETLKW 94+ #define SET_CLOSE_ON_EXEC(fd) \4+ do { \-+ fcntl ((fd), F_SETFD, FD_CLOEXEC); \T-+ vmsfcntl ((fd), F_SETFD, FD_CLOEXEC); \+ } while (0)i4+ #define SET_OPEN_ON_EXEC(fd) \4+ do { \-+ fcntl ((fd), F_SETFD, FD_NCLOEXEC); \ -+ vmsfcntl ((fd), F_SETFD, FD_NCLOEXEC); \e+ } while (0)o + #else)F #define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC))G #define SET_OPEN_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_NCLOEXEC))i + #endif+ + #if 0 /* VMS */m+ #define O_TEXT 0 + #endif  #endif /* ! _FILECNTL_H_ */e5diff -r -c bash-1_14_7/general.c bash1147/general.ce4*** bash-1_14_7/general.c Wed Mar 10 09:43:47 19991--- bash1147/general.c Fri Mar 19 17:49:15 1999n***************y*** 24,30 ****--- 24,32 ---- #include  #include  #include "bashtypes.h"+ #if !defined (VMS) #include + #endif  #if defined (_POSIX_VERSION), # if defined (amiga) && defined (USGr4) # define _POSIX_SOURCE ****************** 45,50 ****--- 47,55 ----  #include  #include "maxpath.h"+ #if defined (USE_VMS)+ #include "vmsutil.h" + #endif  #if !defined (errno) extern int errno;e****************** 318,324 ****--- 323,333 ---- {* int flags, set = 0; + #if defined (USE_VMS)a2+ if ((flags = vmsfcntl (fd, F_GETFL, 0)) < 0) + #elsee/ if ((flags = fcntl (fd, F_GETFL, 0)) < 0)+ + #endif return;   #if defined (O_NONBLOCK)****************** 338,344 ****--- 347,357 ---- #endif /* O_NDELAY */  if (set)+ #if defined (USE_VMS)a&+ vmsfcntl (fd, F_SETFL, flags); + #else+# fcntl (fd, F_SETFL, flags); + #endif }-  ***************f*** 658,664 ****' i = (start < 0) ? 0 : start;V continue;  }! }  }*  if (!*result)m--- 671,677 ----' i = (start < 0) ? 0 : start;t continue;  }! }  }c  if (!*result) ***************=*** 666,671 ****--- 679,685 ---- *result = stub_char; result[1] = '\0';  }l+  return (result); }p *************** *** 680,686 ****--- 694,705 ---- char *result;e int result_len;  @+ #if defined (USE_VMS) /* ??? handled concealed logical names;+ e.g. /disk$axpvmssys -> /disk$axpvmssys/000000 */ & if (!dot_path || *string == '/') + #elsen&+ if (!dot_path || *string == '/') + #endif% result = savestring (string);r  else  {****************** 716,722 ****--- 735,746 ---- if (!string || !*string) return (0);l @+ #if defined (USE_VMS) /* ??? handled concealed logical names;+ e.g. /disk$axpvmssys -> /disk$axpvmssys/000000 */[ if (*string == '/')[ + #else + if (*string == '/')C + #endif return (1);  if (*string++ == '.')w***************o*** 773,779 ****--- 797,807 ----  else! file = savestring (file);| + #if defined (USE_VMS)i#+ if (absolute_pathname (file)) + #elsed5 if ((*file == '/') && absolute_pathname (file)) + #endif return (file);  disposer = file;***************n*** 781,787 ****--- 809,819 ---- {E char *current_dir = xmalloc (2 + MAXPATHLEN + strlen (file));d int dlen;n+ #if defined (USE_VMS)R-+ if (vmsutil_getwd (current_dir) == 0) + #elseh% if (getwd (current_dir) == 0)s + #endif  {  report_error (current_dir); free (current_dir);***************i*** 1093,1099 ****--- 1125,1135 ---- extern char *getcwd (); char *result;_ + #if defined (USE_VMS) 3+ result = vmsutil_getcwd (string, MAXPATHLEN); + #elses+ result = getcwd (string, MAXPATHLEN);o + #endif if (result == NULL) C strcpy (string, "getwd: cannot access parent directories");( return (result);***************m*** 1165,1171 **** * #endif /* NO_READ_RESTART_ON_SIGNAL */ X! #if defined (USG) || defined (AIX) || (defined (_POSIX_VERSION) && defined (Ultrix))L /* USG and strict POSIX systems do not have killpg (). But we use it inM jobs.c, nojobs.c and some of the builtins. This can also be redefined+" as a macro if necessary. */--- 1201,1207 ---- * #endif /* NO_READ_RESTART_ON_SIGNAL */ i! #if defined (USG) || defined (AIX) || (defined (_POSIX_VERSION) && defined (Ultrix)) || defined (VMS)pL /* USG and strict POSIX systems do not have killpg (). But we use it inM jobs.c, nojobs.c and some of the builtins. This can also be redefined " as a macro if necessary. */***************=*** 1271,1273 ****--- 1307,1313 ---- return (oact.sa_handler);  }l #endif /* _POSIX_VERSION */ + + #if defined (USE_VMS) + #include "vmsutil.c" + #endif5diff -r -c bash-1_14_7/general.h bash1147/general.hx4*** bash-1_14_7/general.h Wed Mar 10 09:43:47 19991--- bash1147/general.h Fri Mar 19 17:49:02 1999 ***************]*** 220,227 ****--- 220,229 ----- extern void tilde_initialize __P((void));r  #if !defined (strerror)=+ #ifndef VMSl% extern char *strerror __P((int));  #endif + #endif  #if defined (RLIMTYPE)5 extern RLIMTYPE string_to_rlimtype __P((char *)); *************** *** 243,247 ****--- 245,253 ----4 #if defined (USG) && !defined (HAVE_GETHOSTNAME). extern int gethostname __P((char *, int));) #endif /* USG && !HAVE_GETHOSTNAME */p+ + #if defined (USE_VMS);+ #include "vmsutil.h" + #endif  #endif /* _GENERAL_H */ 1diff -r -c bash-1_14_7/input.c bash1147/input.c;2*** bash-1_14_7/input.c Wed Mar 10 09:43:47 1999/--- bash1147/input.c Fri Mar 19 17:36:15 1999 ***************d*** 137,150 ****--- 137,162 ----I might be able to avoid this by copying the buffered stream verbatims$ to the new file descriptor. */ if (buffers[fd])+ #if defined (USE_VMS) $+ sync_buffered_stream_crlf (fd); + #elseN sync_buffered_stream (fd); + #endif J /* Now take care of duplicating the file descriptor that bash is: using for input, so we can reinitialize it later. */+ #if defined (USE_VMS)++ nfd = vmsfcntl (fd, F_DUPFD, 10); + #else ( nfd = fcntl (fd, F_DUPFD, 10); + #endif if (nfd == -1) {+ #if defined (USE_VMS) *+ if (vmsfcntl (fd, F_GETFD, 0) == 0) + #elsep' if (fcntl (fd, F_GETFD, 0) == 0) + #endif report_errornP ("cannot allocate new file descriptor for bash input from fd %d: %s", fd, strerror (errno));***************c*** 306,320 ****--- 318,350 ---- }1 F /* Read a buffer full of characters from BP, a buffered stream. */#+ #if defined (USE_VMS) /* ??? */ + #define B_USECR 0x100; + #endif static int b_fill_buffer (bp) BUFFERED_STREAM *bp;R {*+ #if defined (USE_VMS)*1+ long plpos = lseek (bp->b_fd, 0, SEEK_CUR);e+ long nlpos;i + #endif+  do  {rA bp->b_used = read (bp->b_fd, bp->b_buffer, bp->b_size);-  }_/ while (bp->b_used < 0 && errno == EINTR);1+ + #if defined (USE_VMS):,+ nlpos = lseek (bp->b_fd, 0, SEEK_CUR);<+ if ((plpos >= 0) && (nlpos >= 0) && (bp->b_used >= 0)) + {,+ if ((plpos + bp->b_used) != nlpos)+ bp->b_flag |= B_USECR;f + } + #endif+  if (bp->b_used <= 0)  {d bp->b_buffer[0] = 0;***************n*** 365,370 ****--- 395,435 ----$ bp->b_used = bp->b_inputp = 0; return (0);  } + + #if defined (USE_VMS) + int #+ sync_buffered_stream_crlf (bfd) + int bfd;)+ {T+ BUFFERED_STREAM *bp;+ int chars_left;+ + bp = buffers[bfd];+ if (!bp)+ return (-1);-+ chars_left = bp->b_used - bp->b_inputp; + + if (chars_left)E + {O2+ lseek (bp->b_fd, -chars_left, SEEK_CUR);#+ if (bp->b_flag & B_USECR)s+ {+ int i = bp->b_inputp;+ int crlf = 0;-+ char *p = bp->b_buffer + bp->b_inputp;)+ + while (i++ < bp->b_used)i+ if (*p++ == '\n')+ crlf++;+ )+ lseek (bp->b_fd, -crlf, SEEK_CUR); + } + }+ $+ bp->b_used = bp->b_inputp = 0;+ return (0);h+ }/ + #endif  int4 buffered_getchar ()n/diff -r -c bash-1_14_7/jobs.c bash1147/jobs.c*1*** bash-1_14_7/jobs.c Wed Mar 10 09:43:47 1999e.--- bash1147/jobs.c Fri Mar 19 17:36:15 1999*************** *** 48,54 ****--- 48,56 ---- #include  #include "filecntl.h") #include + #if !defined (VMS) #include + #endif  #if defined (BUFFERED_INPUT) # include "input.h"***************c*** 74,79 ****--- 76,85 ----+ # endif /* USG | hpux | Xenix | sgi */f  #endif /* !_POSIX_VERSION */ + #if defined (VMS)*+ #undef NEW_TTY_DRIVER + #endif+ F /* Include the right header file for the specific type of terminal+ handler installed on this system. */L  #if defined (NEW_TTY_DRIVER)*************** *** 200,205 ****--- 206,218 ---- commands. */i  static int freeze_jobs_list; + #if defined (VMS)+ # define getpgid(p) 0+ # define getpgrp(p) 0+ # define tcgetpgrp(p) 0+ # define setpgid(t,p) 0+ # define tcsetpgrp(t,p) 0 + #elsec! #if !defined (_POSIX_VERSION)d L /* These are definitions to map POSIX 1003.1 functions onto existing BSD***************V*** 248,253 ****--- 261,267 ---- *oldset = old; }(  #endif /* !_POSIX_VERSION */ + #endif D /* Return the working directory for the current process. UnlikeF job_working_directory, this does not call malloc (), nor do any***************-*** 991,996 ****--- 1005,1013 ----3 (!async_p || default_buffered_input > 0))n6 sync_buffered_stream (default_buffered_input); #endif /* BUFFERED_INPUT */ + #if defined (VMS) + #define fork vfork + #endif 3 /* Create the child, handle severe errors. */  if ((pid = fork ()) < 0)***************0*** 1158,1163 ****--- 1175,1184 ----) static struct termios shell_tty_info;g# #endif /* TERMIOS_TTY_DRIVER */= b+ #if !(defined (NEW_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER) || defined (TERMIOS_TTY_DRIVER))+ static int shell_tty_info; + #endif+ : #if defined (NEW_TTY_DRIVER) && defined (DRAIN_OUTPUT)I /* Since the BSD tty driver does not allow us to change the tty modes*F while simultaneously waiting for output to drain and preserving*************** *** 1800,1805 ****--- 1821,1830 ----& static struct termios save_stty;  #endif b+ #if !(defined (NEW_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER) || defined (TERMIOS_TTY_DRIVER))+ static int save_stty; + #endif+  BLOCK_CHILD (set, oset);5 already_running = (JOBSTATE (job) == JRUNNING);  ****************** 2475,2480 ****--- 2500,2509 ----  # endif /* TERMIOS_LDISC */ return (0); # #endif /* TERMIOS_TTY_DRIVER */e+ + #if defined (VMS) + return (0);S + #endif b #if !defined (NEW_TTY_DRIVER) && !defined (TERMIO_TTY_DRIVER) && !defined (TERMIOS_TTY_DRIVER) return (-1);/diff -r -c bash-1_14_7/jobs.h bash1147/jobs.h;1*** bash-1_14_7/jobs.h Wed Mar 10 09:43:47 19991.--- bash1147/jobs.h Wed Mar 10 09:44:55 1999****************** 282,288 ****  #endif /* !_POSIX_VERSION */  /* System calls. */ I! #if !defined (SunOS5) && !defined (USGr4_2) && !defined (__BSD_4_4__) 0 extern pid_t fork (), getpid (), getpgrp ();4 #endif /* !SunOS5 && !USGr4_2 && !__BSD_4_4__ */ --- 282,288 ----  #endif /* !_POSIX_VERSION */  /* System calls. */_Z! #if !defined (SunOS5) && !defined (USGr4_2) && !defined (__BSD_4_4__) && !defined(VMS)0 extern pid_t fork (), getpid (), getpgrp ();4 #endif /* !SunOS5 && !USGr4_2 && !__BSD_4_4__ */ Qdiff -r -c bash-1_14_7/lib/readline/complete.c bash1147/lib/readline/complete.c B*** bash-1_14_7/lib/readline/complete.c Wed Mar 10 09:44:01 1999?--- bash1147/lib/readline/complete.c Fri Mar 19 15:37:37 1999)***************X*** 963,970 **** {x struct stat finfo; int character, r;y! ! #if defined (S_ISLNK) # r = lstat (filename, &finfo);  #else " r = stat (filename, &finfo);--- 963,969 ---- {f struct stat finfo; int character, r; +! #if defined (S_ISLNK) && !defined (VMS)t# r = lstat (filename, &finfo);  #elseI" r = stat (filename, &finfo);***************"*** 1015,1021 **** int state;_ char *text; {a! #if defined (__GO32__) return (char *)NULL; #else /* !__GO32__ */h+ static char *username = (char *)NULL;]--- 1014,1020 ---- int state; char *text; {e/! #if defined (__GO32__) || defined (USE_VMS)= return (char *)NULL; #else /* !__GO32__ */)+ static char *username = (char *)NULL;iOdiff -r -c bash-1_14_7/lib/readline/display.c bash1147/lib/readline/display.c*A*** bash-1_14_7/lib/readline/display.c Wed Mar 10 09:44:01 1999U>--- bash1147/lib/readline/display.c Wed Mar 10 09:45:18 1999****************** 62,68 ****--- 62,72 ----, extern int terminal_can_insert, term_xn; ) extern void _rl_output_some_chars ();f+ #ifdef _BSD44_CURSES1+ extern void _rl_output_character_function (); + #else/0 extern int _rl_output_character_function (); + #endif % extern int _rl_output_meta_chars;** extern int _rl_horizontal_scroll_mode;***************d*** 1132,1138 ****I /* If IC is defined, then we do not have to "enter" insert mode. */f if (term_IC)  { "! char *tgoto (), *buffer;- buffer = tgoto (term_IC, 0, count);r; tputs (buffer, 1, _rl_output_character_function);u0 _rl_output_some_chars (string, count);--- 1136,1145 ----I /* If IC is defined, then we do not have to "enter" insert mode. */  if (term_IC)  {! #ifndef VMS ! char *tgoto (); ! #endif! char *buffer;=- buffer = tgoto (term_IC, 0, count); ; tputs (buffer, 1, _rl_output_character_function);f0 _rl_output_some_chars (string, count);*************** *** 1186,1192 ****  if (term_DC && *term_DC)  { "! char *tgoto (), *buffer;1 buffer = tgoto (term_DC, count, count);5? tputs (buffer, count, _rl_output_character_function);m  }e--- 1193,1202 ----  if (term_DC && *term_DC)  {C! #ifndef VMSd! char *tgoto ();i ! #endif! char *buffer;E1 buffer = tgoto (term_DC, count, count); ? tputs (buffer, count, _rl_output_character_function);  }Odiff -r -c bash-1_14_7/lib/readline/history.c bash1147/lib/readline/history.cbA*** bash-1_14_7/lib/readline/history.c Wed Mar 10 09:44:01 1999I>--- bash1147/lib/readline/history.c Fri Mar 19 15:23:18 1999***************R*** 25,30 ****--- 25,34 ----2 you can call. I think I have done that. */ #define READLINE_LIBRARY + #ifdef HAVE_CONFIG_H+ #include "config.h"f + #endif+  #include  #include  #include nQdiff -r -c bash-1_14_7/lib/readline/readline.c bash1147/lib/readline/readline.c B*** bash-1_14_7/lib/readline/readline.c Wed Mar 10 09:44:02 1999?--- bash1147/lib/readline/readline.c Fri Mar 19 15:40:04 1999***************A*** 67,73 ****--- 67,75 ----, to be visible to readline callers. */ = /* Functions imported from other files in the library. */+ #ifndef VMSr extern char *tgetstr (); + #endif; extern void rl_prep_terminal (), rl_deprep_terminal ();U ' extern void _rl_bind_if_unbound ();****************** 102,108 ****--- 104,114 ----  int _rl_dispatch ();  void _rl_set_screen_size ();+ #ifdef _BSD44_CURSES*+ void _rl_output_character_function (); + #else) int _rl_output_character_function ();b + #endif & static char *readline_internal ();2 static void readline_initialize_everything ();***************.*** 526,531 ****--- 532,538 ----3 result = ioctl (tty, FIONREAD, &chars_avail);  #endif + #ifndef VMS* #if defined (O_NDELAY) if (result == -1)c  {i***************e*** 541,546 ****--- 548,554 ----  return;  }) #endif /* O_NDELAY */> + #endif F /* If there's nothing available, don't waste time trying to read something. */***************-*** 982,991 ****. /* Initialize the terminal interface. */& init_terminal_io ((char *)NULL); ! #if !defined (__GO32__) 6 /* Bind tty characters to readline functions. */# readline_default_bindings ();h #endif /* !__GO32__ */ * /* Initialize the function names. */ rl_initialize_funmap ();--- 990,1002 ----. /* Initialize the terminal interface. */& init_terminal_io ((char *)NULL); 7! #if !defined (__GO32__) && !defined (_BSD44_CURSES)f6 /* Bind tty characters to readline functions. */# readline_default_bindings (); #endif /* !__GO32__ */+ #ifdef _BSD44_CURSES+ initscr (); + #endif * /* Initialize the function names. */ rl_initialize_funmap ();*************** *** 1027,1037 ****--- 1038,1050 ----D /* If this system allows us to look at the values of the regularA input editing characters, then bind them to their readlinedC equivalents, iff the characters are not bound to keymaps. */ + #if !defined(_BSD44_CURSES)  static voidd  readline_default_bindings () {c. rltty_set_default_bindings (_rl_keymap); }/ + #endif  static voide bind_arrow_keys_internal ()****************** 1373,1378 ****--- 1386,1394 ---- #else /* !__GO32__ */r  char *term, *buffer;+ #ifdef VMS+ char *termcap; + #endif int tty; Keymap xkeymap;  ***************V*** 1486,1498 **** }e , /* A function for the use of tputs () */! int(% _rl_output_character_function (c)e int c;  {" return putc (c, out_stream); }e! B /* Write COUNT characters from STRING to the output stream. */ void) _rl_output_some_chars (string, count)a--- 1502,1520 ---- }  , /* A function for the use of tputs () */! #ifdef _BSD44_CURSES! void% _rl_output_character_function (c)+ {+ putc (c, out_stream);E+ }e + #elseI)+ int _rl_output_character_function (c)R int c;i {_" return putc (c, out_stream); } ! #endifB /* Write COUNT characters from STRING to the output stream. */ void) _rl_output_some_chars (string, count) ***************/*** 3302,3307 ****--- 3324,3333 ---- if (isatty (0))R" return (getkey () & 0x7F); #endif /* __GO32__ */ + #ifdef _BSD44_CURSES+ if (isatty (0))&+ return getch (); + #endif  while (1))  {u*************** *** 3315,3320 ****--- 3341,3347 ---- if (result == 0) return (EOF); + #ifndef VMSe #if defined (EWOULDBLOCK)*# if (errno == EWOULDBLOCK)e {****************** 3347,3352 ****--- 3374,3380 ----  } }7 #endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */d + #endif  #if !defined (__GO32__)/F /* If the error that we received was SIGINT, then try again,Mdiff -r -c bash-1_14_7/lib/readline/rldefs.h bash1147/lib/readline/rldefs.h(@*** bash-1_14_7/lib/readline/rldefs.h Wed Mar 10 09:44:02 1999=--- bash1147/lib/readline/rldefs.h Wed Mar 10 09:45:19 1999e***************!*** 47,52 ****--- 47,58 ---- # undef HAVE_BSD_SIGNALSl  #endif + #ifdef VMS+ #undef NEW_TTY_DRIVER1+ #define _BSD44_CURSES 1 + #include + #endif+ ' /* System V machines use termio. */1! #if !defined (_POSIX_VERSION),R # if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || \****************** 87,92 ****--- 93,102 ---- # include  #endif + #if 16.+ # define D_NAMLEN(d) strlen ((d)->d_name) + #elser+ I #if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3))m" # if !defined (HAVE_DIRENT_H) # define HAVE_DIRENT_H**************** *** 111,116 ****--- 121,127 ---- # define dirent direct  # endif /* !dirent */ #endif /* !HAVE_DIRENT_H */ + #endif A #if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux)% # if defined (HAVE_SYS_STREAM_H)xKdiff -r -c bash-1_14_7/lib/readline/rltty.c bash1147/lib/readline/rltty.ch?*** bash-1_14_7/lib/readline/rltty.c Wed Mar 10 09:44:02 1999m<--- bash1147/lib/readline/rltty.c Fri Mar 19 15:40:32 1999***************r*** 126,137 ****--- 126,146 ---- extern char *term_ks;r extern char *term_ke;a + #ifdef _BSD44_CURSES+ static void + outchar (c)*+ int c;6+ {+ putc (c, rl_outstream);t+ }a + #elset static int outchar (c)  int c;h {f$ return putc (c, rl_outstream); }r + #endif 3 /* Turn on/off the meta key depending on ON. */_ static voidn****************** 347,352 ****--- 356,362 ---- }  * #else /* !defined (NEW_TTY_DRIVER) */+ #ifndef _BSD44_CURSES*  #if !defined (VMIN)t # define VMIN VEOFt***************f*** 495,500 ****--- 505,511 ---- 6 #endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */ }o+ #endif /* _BSD44_CURSES */  #endif /* NEW_TTY_DRIVER */ L /* Put the terminal in CBREAK mode so that we can detect key presses. */***************t*** 504,510 **** {r #if !defined (__GO32__)(% int tty = fileno (rl_instream);! TIOTYPE tio;  if (terminal_prepped)* return; --- 515,523 ---- {0 #if !defined (__GO32__)b% int tty = fileno (rl_instream);)! #ifndef _BSD44_CURSESm! TIOTYPE tio; ! #endif  if (terminal_prepped) return;m****************** 512,517 ****--- 525,536 ----= /* Try to keep this function from being INTerrupted. */  block_sigint (); + #ifdef _BSD44_CURSES+ crmode ();+ noecho ();+ nodelay (stdscr, 0); + #else+ + if (get_tty_settings (tty, &tio) < 0)  {e release_sigint ();***************=*** 527,532 ****--- 546,552 ---- release_sigint (); return;n  } + #endif  control_meta_key (1);/  #if 0a***************/*** 552,557 ****--- 572,581 ----= /* Try to keep this function from being INTerrupted. */l block_sigint (); + #ifdef _BSD44_CURSES+ nocrmode ();+ echo (); + #elsey control_meta_key (0);d  #if 0/ control_keypad (0);A***************f*** 563,569 **** release_sigint (); return;u  }>!  terminal_prepped = 0;i  release_sigint ();--- 587,593 ---- release_sigint (); return;.  }a ! #endif terminal_prepped = 0;   release_sigint ();***************i*** 640,645 ****--- 664,670 ----& /* Default Key Bindings */ /* */J /* **************************************************************** */+ #if !defined(_BSD44_CURSES)n void% rltty_set_default_bindings (kmap)f Keymap kmap;e***************e*** 703,705 ****--- 728,731 ----  }i  #endif /* !NEW_TTY_DRIVER */ } + #endifKdiff -r -c bash-1_14_7/lib/readline/tilde.c bash1147/lib/readline/tilde.c_?*** bash-1_14_7/lib/readline/tilde.c Wed Mar 10 09:44:03 1999_<--- bash1147/lib/readline/tilde.c Fri Mar 19 15:24:08 1999****************** 292,298 ****--- 292,300 ---- free (dirname); dirname = temp_name;*  }+ #ifndef VMS  endpwent ();- + #endif free (username);A }  }Odiff -r -c bash-1_14_7/lib/readline/vi_mode.c bash1147/lib/readline/vi_mode.c=A*** bash-1_14_7/lib/readline/vi_mode.c Wed Mar 10 09:44:03 19994>--- bash1147/lib/readline/vi_mode.c Wed Mar 10 09:45:20 1999****************** 349,355 ****--- 349,359 ---- }s 4 /* Move forward a word the way that 'W' does. */+ #ifdef VMS+ rl_vi_fwword (count) + #elsee rl_vi_fWord (count) + #endif int count;; {0 while (count-- && rl_point < (rl_end - 1))***************e*** 365,371 ****--- 369,379 ---- return (0);e }  + #ifdef VMS+ rl_vi_bwword (count) + #else  rl_vi_bWord (count)u + #endif int count; {I% while (count-- && rl_point > 0)***************o*** 388,394 ****--- 396,406 ---- return (0);i }S + #ifdef VMS+ rl_vi_ewword (count) + #elset rl_vi_eWord (count)d + #endif int count;/ {30 while (count-- && rl_point < (rl_end - 1))7diff -r -c bash-1_14_7/machines.h bash1147/machines.hm5*** bash-1_14_7/machines.h Wed Mar 10 09:43:47 1999*2--- bash1147/machines.h Wed Mar 10 09:44:55 1999***************l*** 586,591 ****--- 586,623 ----  #if defined (i386) + /* MS-DOS(DJGPP) */r3+ # if !defined (done386) && defined (__DJGPP__)e+ # define done386 + # define M_MACHINE "PCAT"+ # define M_OS "MSDOS"+ # define USE_DOS"+ # define REQUIRED_LIBRARIES+ # undef HAVE_SYS_SIGLISTd+ # undef USE_GNU_MALLOC + # define USE_GNU_TERMCAP*+ # define HAVE_SETLINEBUF + # define HAVE_VFPRINTF + /*# define HAVE_GETGROUPS*/X+ # define SYSDEP_CFLAGS -DUSE_DOS -DHAVE_BCOPY -DHAVE_UID_T -DHAVE_GETDTABLESIZE \+ -DHAVE_GETHOSTNAME+ # define HAVE_STRERROR1+ # define HAVE_STRCASECMPf+ # define HAVE_DIRENT(+ # define VOID_SIGHANDLERa(+ /* following comes from sysdefs.h */+ # define HAVE_WAIT_Hu+ # define HAVE_RESOURCE*+ # define HAVE_SYS_PARAM+ # define HAVE_UNISTD_H+ # define HAVE_STDLIB_Hr+ # define HAVE_LIMITS_H1+ # define HAVE_DIRENT_HA+ # define HAVE_STRING_H(+ # define HAVE_VARARGS_H+ # define HAVE_BISON + # endif+ 0 /* Sequent Symmetry running Dynix/ptx 2.x */3 # if !defined (done386) && defined (_SEQUENT_) # define done386***************c*** 2229,2234 ****--- 2261,2283 ---- # undef HAVE_ALLOCA # undef HAVE_WAIT_H #endif /* cadmus */_+ + /* X68000 */+ #if defined (HUMAN68K) + # define M_MACHINE "x68000"+ # define M_OS "Human68k"( + # define REQUIRED_LIBRARIES+ # define HAVE_SYS_SIGLIST+ # undef USE_GNU_MALLOC+ # define USE_GNU_TERMCAP + # define HAVE_VFPRINTFQ+ # define SYSDEP_CFLAGS -DUSE_DOS -DHAVE_BCOPY -DHAVE_RESOURCE -DHAVE_UID_T \ + -D__NO_SIGNAL_INLINE__+ # define HAVE_STRERRORF+ # define HAVE_STRCASECMP + # define HAVE_DIRENT+ # define VOID_SIGHANDLERO + #endif J /* **************************************************************** */ /* */9diff -r -c bash-1_14_7/mailcheck.c bash1147/mailcheck.c6*** bash-1_14_7/mailcheck.c Wed Mar 10 09:43:47 19993--- bash1147/mailcheck.c Fri Mar 19 17:36:15 1999 ***************r*** 21,32 ****--- 21,38 ---- #include  #include "bashtypes.h" #include "posixstat.h"+ #if !defined (VMS) #include + #endif #include "bashansi.h"7 #include "shell.h" #include "maxpath.h" #include "execute_cmd.h" #include + + #if defined (USE_VMS)RJ+ extern char *extract_unit (char *string, int *p_index, int separator); + #endif  #ifndef NOW(, #define NOW ((time_t)time ((time_t *)0))7diff -r -c bash-1_14_7/make_cmd.c bash1147/make_cmd.c5*** bash-1_14_7/make_cmd.c Wed Mar 10 09:43:47 19992--- bash1147/make_cmd.c Fri Mar 19 17:36:15 1999***************_*** 50,55 ****--- 50,58 ----7 temp = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));X' temp->word = savestring (string); A temp->quoted = temp->dollar_present = temp->assignment = 0;*+ #if defined (USE_VMS)*+ temp->expansion = 0; + #endif  while (*string)  {***************_*** 423,430 ****--- 426,438 ---- len = strlen (line);N5 if (len + document_index >= document_size)T { + #if 0cA document_size = document_size ? 2 * (document_size + len) : 1000; /* XXX */r + #elseMA+ document_size = document_size ? 2 * (document_size + len)9%+ : len + document_index + 1;* + #endif6 document = xrealloc (document, document_size); }a 5diff -r -c bash-1_14_7/makefile. bash1147/makefile. 4*** bash-1_14_7/makefile. Wed Mar 10 09:43:47 19991--- bash1147/makefile. Wed Mar 10 09:44:55 1999t*************** *** 19,26 **** # MAKE = make RM = rm -ft SHELL = /bin/shd! GAWK = awk! # GAWK = gawke F # Force CPPNAME to be the name of your C preprocesor if Bash can'tD # find it. For instance, `CPPNAME=/usr/libexec/cpp' on 4.4 BSD.--- 19,26 ---- # MAKE = make RM = rm -fM SHELL = /bin/shN! # GAWK = awk! GAWK = gawk* F # Force CPPNAME to be the name of your C preprocesor if Bash can'tD # find it. For instance, `CPPNAME=/usr/libexec/cpp' on 4.4 BSD.****************** 74,80 ****@ @test -s bash-Makefile || { rm -f bash-Makefile ; exit 1; }  sysdefs.h: $(MKSYSDEFS) '! $(SHELL) $(MKSYSDEFS) -s $(srcdir)n O # This is also performed by support/mksysdefs, but there's no way to changeO # it if cpp-Makefile is changed without changing anything else, since there --- 74,80 ----@ @test -s bash-Makefile || { rm -f bash-Makefile ; exit 1; }  sysdefs.h: $(MKSYSDEFS)l;! $(SHELL) $(MKSYSDEFS) -s $(srcdir) -i $(DJDIR)/include1 O # This is also performed by support/mksysdefs, but there's no way to change*O # it if cpp-Makefile is changed without changing anything else, since there -diff -r -c bash-1_14_7/news. bash1147/news.e0*** bash-1_14_7/news. Wed Mar 10 09:43:48 1999---- bash1147/news. Wed Mar 10 09:44:56 1999;***************=*** 1,10 *****I! This file documents the bugs fixed between this release, bash-1.14.7,-! and the last public bash release, 1.14.6.k  1. Bugs fixed in Bash L! a. A memory leak that caused long-running scripts to eventually consume'! all available memory was fixed.i L! b. A sign-extension bug that caused a security hole for non-interactive! shells was fixed.y--- 1,55 ----/I! This file documents the bugs fixed between this release, bash-1.14.6, -! and the last public bash release, 1.14.5.   1. Bugs fixed in Bash K! a. Fix to the `fc' builtin to prevent core dumps when the history listi! is empty.e L! b. Fix to `getopts' to keep it from running off the end of the array of! positional parameters.! A! c. FIFOs are now created with mode 600 for security reasons. ! L! d. The list of active file descriptors connected to files in /dev/fd is7! now properly zeroed when allocated or extended.o! K! e. Fix to trap so that the exit status is preserved around the command*K! executed via `trap 0', unless that command contains a call to exit.YN! If a call to exit appears, that will set the exit value for the shell.! K! f. Fixed an off-by-one error that caused words to be split incorrectly4 ! when IFS was set to "'".! J! g. Fixed an off-by-one error that caused completion to sometimes fail@! when escaped single quotes appeared in the command line.! M! h. Fixed a parser error that occasionally resulted in close braces (`}')f! causing syntax errors.! A! i. There is now a machine description for HPUX version 10.x.n! N! j. Fixed an obscure bug that caused machines without restartable syscallsN! to drop backslash-escaped characters when reading here documents in an! interactive shell.! N! k. Fixed a bug that caused FIGNORE to occasionally allow some completions! that should be ignored.)! H! l. New machine descriptions: NetBSD/pmax, Linux/m68k, BSD/OS/sparc.! H! m. Fixed a bug that caused the `vi' mode `v' command to execute the<! original command after it was changed in the editor.! Q! n. Fixed some substitution bugs that left occasional stray CTLNUL characterse-! in the results of variable expansion. ! ,! o. Updated machine descriptions: SCOv5.! ! 2. Bugs fixed in Readline! K! a. Fix to the history searching functions so a null search string doest(! not cause readline to seg fault.! L! b. Fixed a bug in the completion code which caused words appearing on aA! line after a quoted string to not be completed correctly._3diff -r -c bash-1_14_7/nojobs.c bash1147/nojobs.c73*** bash-1_14_7/nojobs.c Wed Mar 10 09:43:48 1999*0--- bash1147/nojobs.c Fri Mar 19 17:36:15 1999***************8*** 26,31 ****--- 26,35 ---- #include 8 #include  + #ifdef VMS+ #include + #endif+  #include "config.h"O #include "command.h" #include "general.h"*************** *** 38,44 **** # include "input.h"  #endif 3! #if !defined (USG) && !defined (_POSIX_VERSION)T # include  #elseT" # if defined (_POSIX_VERSION)--- 42,50 ---- # include "input.h"  #endif ! #if defined (USE_VMS)\! # include "vmstermios.h"5! #elif !defined (USG) && !defined (_POSIX_VERSION)R # include  #else(" # if defined (_POSIX_VERSION)***************m*** 59,65 ****0 # define killpg(pg, sig) kill(-(pg),(sig))& #endif /* USG || _POSIX_VERSION */ ! #if defined (USG)U% # define siginterrupt(sig, code)r #endif /* USG */ --- 65,71 ----0 # define killpg(pg, sig) kill(-(pg),(sig))& #endif /* USG || _POSIX_VERSION */ *! #if defined (USG) || defined (USE_VMS)% # define siginterrupt(sig, code)/ #endif /* USG */ ***************U*** 302,308 ****--- 308,318 ---- retry_fork:  #endif /* _POSIX_VERSION */- + #if defined (USE_VMS) 0+ if ((pid = vmsutil_make_child_pid ()) < 0) + #elseX if ((pid = fork ()) < 0) + #endif  {A  #if defined (_POSIX_VERSION)O /* Posix systems with a non-blocking waitpid () system call available***************M*** 319,325 ****  throw_to_top_level ();  }! f if (pid == 0)S  {E  #if defined (BUFFERED_INPUT)--- 329,335 ----  throw_to_top_level ();  } !  if (pid == 0)  {  #if defined (BUFFERED_INPUT)***************d*** 362,367 ****--- 372,380 ----! last_asynchronous_pid = pid;*  add_pid (pid);+ #if defined (USE_VMS)i$+ vmsutil_current_pid = pid; + #endif  }  return (pid);9 }-***************k*** 477,482 ****--- 490,506 ---- if (!interactive_shell)-N old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); + #if defined (USE_VMS)M+ {i%+ status = vmsutil_wait_status;i0+ if ((status & 0x0000ff00) == 0x0000ff00)+ status &= 0x000000ff;e+ errno = 0;+ got_pid = pid;+ + last_made_pid = NO_PID;+ }c + #elsetR while ((got_pid = WAITPID (-1, &status, 0)) != pid) /* XXX was pid now -1 */  {f- if (got_pid < 0 && errno == ECHILD) ***************_*** 493,498 ****--- 517,523 ---- else if (got_pid > 0):& set_pid_status (got_pid, status);  }6+ #endif /* !USE_VMS */_ ' set_pid_status (got_pid, status);p 1diff -r -c bash-1_14_7/parse.y bash1147/parse.yp2*** bash-1_14_7/parse.y Wed Mar 10 09:43:48 1999/--- bash1147/parse.y Fri Mar 19 17:48:13 1999***************V*** 27,32 ****--- 27,36 ---- #include "flags.h" #include "input.h" + #if defined (USE_VMS),+ #include "vmsutil.h" + #endif+  #if defined (READLINE)$ # include  #endif /* READLINE */ ***************t*** 2406,2411 ****--- 2410,2418 ----2 the_word->dollar_present = dollar_present;" the_word->quoted = quoted;2 the_word->assignment = assignment (token);+ #if defined (USE_VMS)f + the_word->expansion = 0; + #endif  yylval.word = the_word;c result = WORD;****************** 2614,2619 ****--- 2621,2627 ----  while (c = *string++)W  {9+ * if (posixly_correct && c == '!') { if (*string == '!')*************** *** 2723,2733 ****--- 2731,2749 ----& temp = get_string_value ("PWD");  if (!temp)+ #if defined (USE_VMS)!+ vmsutil_getwd (t_string);A + #elsee getwd (t_string); + #endif  else  strcpy (t_string, temp);  #else + #if defined (USE_VMS)a+ vmsutil_getwd (t_string); + #elseP getwd (t_string);o + #endif #endif /* EFFICIENT */  if (c == 'W')A9diff -r -c bash-1_14_7/print_cmd.c bash1147/print_cmd.c 6*** bash-1_14_7/print_cmd.c Wed Mar 10 09:43:48 19993--- bash1147/print_cmd.c Fri Mar 19 17:36:15 1999S***************(*** 30,36 ****--- 30,40 ---- #endif /* !HAVE_STRING_H */r  #include "shell.h"+ #if defined (VMS)i+ #include "y_tab.h" + #elseh #include "y.tab.h" + #endif #include "stdc.h"@  #include "builtins/common.h" 1diff -r -c bash-1_14_7/shell.c bash1147/shell.cS2*** bash-1_14_7/shell.c Wed Mar 10 09:43:48 1999/--- bash1147/shell.c Fri Mar 19 17:47:48 1999b***************,*** 63,68 ****--- 63,73 ----  #include  + #if defined (USE_VMS) + #include "vmsutil.h"+ #include s + #endif+ 4 #if defined (USG) && !defined (HAVE_GETPW_DECLS)& extern struct passwd *getpwuid ();) #endif /* USG && !HAVE_GETPW_DECLS */o***************x*** 174,180 ****--- 179,189 ---- time_t shell_start_time; * /* The name of the .(shell)rc file. */+ #if defined (VMS)y3+ static char *bashrc_file = "sys$login:.bashrc";c + #else + static char *bashrc_file = "~/.bashrc"; + #endif F /* Non-zero means to act more like the Bourne shell on startup. */ static int act_like_sh = 0;***************t*** 248,253 ****--- 257,271 ----/ int top_level_arg_index, read_from_stdin;e FILE *default_input; + #if defined (USE_VMS)i+ setlocale (LC_CTYPE, "");c+ vmsutil_import_envvar ();?+ argv [0] = savestring (TO_CANONICAL_FILE_SPEC (argv[0]));m#+ vmsutil_delsysroot (argv[0]);+ vmsutil_reserve_fds ();+ vmsutil_save_cwd ();+ #endif /* !USE_VMS */e+ A /* There is a bug in the NeXT 2.1 rlogind that causes opensc  of /dev/tty to fail. */! #if defined (RLOGIN_PGRP_BUG)d*************** *** 507,512 ****--- 525,531 ---- #endif /* JOB_CONTROL */  } + #if !defined (USE_VMS) #define CLOSE_FDS_AT_LOGIN$ #if defined (CLOSE_FDS_AT_LOGIN) /**************** *** 522,527 ****--- 541,547 ---- close (i);r  }u# #endif /* CLOSE_FDS_AT_LOGIN */+ #endif /* USE_VMS */ G /* From here on in, the shell must be a normal functioning shell.eG Variables from the environment are expected to be set, etc. */*************** *** 632,637 ****--- 652,658 ----  {b int fd;  char *filename;+ struct stat statbuff;e  free (dollar_vars[0]);8 dollar_vars[0] = savestring (argv[arg_index]);***************c*** 748,759 **** else if (!interactive)H /* In this mode, bash is reading a script from stdin, which is a& pipe or redirected file. */  #if defined (BUFFERED_INPUT);! default_buffered_input = fileno (stdin); /* == 0 */  #else B-! setbuf (default_input, (char *)NULL);.  #endif /* !BUFFERED_INPUT */! , /* Bind remaining args to $1 ... $n */ {t, WORD_LIST *args = (WORD_LIST *)NULL;--- 769,784 ---- else if (!interactive)H /* In this mode, bash is reading a script from stdin, which is a& pipe or redirected file. */ + {.+ #if defined (USE_VMS)i+ fflush (stdin);i + #endif  #if defined (BUFFERED_INPUT)=! default_buffered_input = fileno (stdin); /* == 0 */ #else e/! setbuf (default_input, (char *)NULL);  #endif /* !BUFFERED_INPUT */ ! }t, /* Bind remaining args to $1 ... $n */ {-, WORD_LIST *args = (WORD_LIST *)NULL;***************d*** 773,778 ****--- 798,811 ----* unset_nodelay_mode (fileno (stdin));  #endif /* !BUFFERED_INPUT */ :+ #if 0 /* def VMS Bug in DEC C RTL, fixed in VMS 7.2 */ + #if defined (BUFFERED_INPUT)2+ lseek (default_buffered_input, 0, SEEK_SET); + #elsee*+ lseek (fileno (stdin), 0, SEEK_SET); + #endif + #endif+ I /* with_input_from_stdin really means `with_input_from_readline' */d* if (interactive && !no_line_editing)! with_input_from_stdin ();e****************** 845,856 ****) if (login_shell && !no_profile)  {U if (act_like_sh)5 maybe_execute_file ("~/.profile", 1);V else { E! if (maybe_execute_file ("~/.bash_profile", 1) == 0)9> if (maybe_execute_file ("~/.bash_login", 1) == 0)4 maybe_execute_file ("~/.profile", 1); }d  }u --- 878,908 ----) if (login_shell && !no_profile)d  {, if (act_like_sh)+ #if defined (USE_VMS)O + {A+ if (maybe_execute_file ("sys$login:.profile", 1) == 0)u3+ maybe_execute_file ("sys$login:_profile", 1);* + } + #else 5 maybe_execute_file ("~/.profile", 1);f + #endif else {V! #if defined (USE_VMS)tM! if (maybe_execute_file ("sys$login:.bash_profile", 1) == 0)dA! if (maybe_execute_file ("sys$login:_bash_profile", 1) == 0)x<! if (maybe_execute_file ("sys$login:_bprof", 1) == 0)C! if (maybe_execute_file ("sys$login:.bash_login", 1) == 0)pE! if (maybe_execute_file ("sys$login:_bash_login", 1) == 0)i<! if (maybe_execute_file ("sys$login:_blogin", 1) == 0)9! if (maybe_execute_file ("sys$login:.profile", 1)=! == 0)8! maybe_execute_file ("sys$login:_profile", 1); ! #else*>! if (maybe_execute_file ("~/.bash_profile", 1) == 0)> if (maybe_execute_file ("~/.bash_login", 1) == 0)4 maybe_execute_file ("~/.profile", 1); + #endif }*  } *************** *** 878,884 ****--- 930,942 ----' if (!act_like_sh && !no_rc &&gB (interactive_shell || (isnetconn (fileno (stdin)) &&( local_pending_command)))+ #if defined (USE_VMS)f1+ if (maybe_execute_file (bashrc_file, 1) == 0t;+ && strcmp (bashrc_file, "sys$login:.bashrc") == 0)i3+ maybe_execute_file ("sys$login:_bashrc", 1); + #else0 maybe_execute_file (bashrc_file, 1); + #endif  }n F /* Try a TMB suggestion. If running a script, then execute the***************9*** 948,959 ****" int force_noninteractive; {: jmp_buf old_return_catch;t3! int return_val, fd, tresult, old_interactive; char *filename, *string; struct stat file_info; & filename = tilde_expand (fname);% fd = open (filename, O_RDONLY);9  if (fd < 0)y  { --- 1006,1023 ----" int force_noninteractive; {  jmp_buf old_return_catch; :! int return_val, fd, tresult, old_interactive, tnext; char *filename, *string; struct stat file_info; & filename = tilde_expand (fname);+ #if defined (USE_VMS)*+ errno = 0;0+ filename = vmsutil_expand_path (filename);%+ fd = open (filename, O_RDONLY);n + #else % fd = open (filename, O_RDONLY);_ + #endif  if (fd < 0);  {e****************** 975,981 ****  } < string = (char *)xmalloc (1 + (int)file_info.st_size);5! tresult = read (fd, string, file_info.st_size);   { int tt = errno;t--- 1039,1051 ----  }  < string = (char *)xmalloc (1 + (int)file_info.st_size);! tnext = 0; ! do * ! { B! tresult = read (fd, &string [tnext], file_info.st_size);! tnext += tresult;i! } while (tresult > 0);! tresult = tnext;  { int tt = errno;***************l*** 983,994 ****--- 1053,1072 ---- errno = tt;e }S + #if defined (USE_VMS))+ if (tresult < 0) + #elsen' if (tresult != file_info.st_size) + #endif  {= free (string);# goto file_error_and_exit;.  }a+ #if defined (USE_VMS)a+ string[tresult] = '\0';1 + #elsed' string[file_info.st_size] = '\0';* + #endif  return_catch_flag++;P xbcopy ((char *)return_catch, (char *)old_return_catch, sizeof (jmp_buf));***************_*** 1123,1128 ****--- 1201,1209 ---- {f executing = 1;* execute_command (current_command);+ #if defined (USE_VMS)l+ vmsutil_pipe_clean (0);1 + #endif }   exec_done:h***************r*** 1310,1315 ****--- 1391,1401 ----  else*3 current_user.shell = savestring ("/bin/sh");>8 current_user.home_dir = savestring (entry->pw_dir);+ #if defined (USE_VMS)s.+ current_user.shell = savestring ("bash");'+ current_user.home_dir = savestringc:+ (to_canonical_dir_spec (current_user.home_dir, 0)); + #endif  }x  else  { ***************i*** 1318,1324 ****--- 1404,1412 ----. current_user.home_dir = savestring ("/");  }t + #if !defined (VMS) endpwent (); + #endif }  ; /* Initialize our interface to the tilde expander. */n***************t*** 1374,1380 ****--- 1462,1472 ---- M /* Ensure that the default startup file is used. (Except that we don't 8 execute this file for reinitialized shells). */+ #if defined (VMS)(+ bashrc_file = "sys$login:.bashrc"; + #else"  bashrc_file = "~/.bashrc"; + #endif M /* Delete all variables and functions. They will be reinitialized when(& the environment is parsed. */***************a*** 1589,1594 ****--- 1681,1687 ----  #endif /* !_POSIX_VERSION */ + #if !defined (USE_VMS)9 #if defined (JOB_CONTROL) || defined (_POSIX_VERSION)BG /* All shells use the signal mask they inherit, and pass it alongdK to child processes. Children will never block SIGCHLD, though. */n***************N*** 1596,1601 ****--- 1689,1695 ----A sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &top_level_mask);+ sigdelset (&top_level_mask, SIGCHLD);S. #endif /* JOB_CONTROL || _POSIX_VERSION */+ #endif /* USE_VMS */ I /* And, some signals that are specifically ignored by the shell. */n, set_signal_handler (SIGQUIT, SIG_IGN);****************** 1714,1719 ****--- 1808,1828 ----2 set_signal_handler (sig, sigint_sighandler);  #endif #+ #if defined (USE_VMS) /* ??? */e8+ #define SIG_TRAPPED 0x1 /* Currently trapped. */J+ #define SIG_INPROGRESS 0x10 /* Signal handler currently executing. */+ {v2+ extern int vmsutil_get_signal_modes (int);7+ extern int vmsutil_set_signal_modes (int, int);i+ int modes;+ 2+ modes = vmsutil_get_signal_modes (SIGINT);>+ if (interrupt_state == 0 && interrupt_immediately == 0Z+ && (modes & (SIG_INPROGRESS | SIG_TRAPPED)) == (SIG_INPROGRESS | SIG_TRAPPED))E+ vmsutil_set_signal_modes (SIGINT, modes & ~SIG_INPROGRESS);N+ }- + #endif+ L /* interrupt_state needs to be set for the stack of interrupts to work5 right. Should it be set unconditionally? */i if (!interrupt_state)e****************** 1743,1750 ****--- 1852,1873 ---- void show_shell_version ()  {_7+ #if defined (USE_VMS) /* ??? fix version numbers */ + { :+ char *p = savestring (base_pathname (shell_name));+ *+ if (strlen (p) >= sizeof (".exe"))L+ if (stricmp (p + strlen (p) - (sizeof (".exe") - 1), ".exe") == 0)2+ p[strlen (p) - (sizeof (".exe") - 1)] = '\0';E+ printf ("GNU %s, version %s%s\n", p, shell_version_string (), $+ vmsutil_version_string ());+ + free (p);,+ } + #elseA printf ("GNU %s, version %s\n", base_pathname (shell_name),u! shell_version_string ()); + #endif }n , #if !defined (USG) && defined (ENOTSOCK)***************m*** 1771,1776 ****--- 1894,1902 ----$ return (S_ISCHR (sb.st_mode));" #else /* !USGr4 && !USGr4_2 */  # if defined (HAVE_SOCKETS)+ #if defined (VMS) + unsigned + #endif int rv, l; struct sockaddr sa;( 1diff -r -c bash-1_14_7/subst.c bash1147/subst.cf2*** bash-1_14_7/subst.c Wed Mar 10 09:43:49 1999/--- bash1147/subst.c Fri Mar 19 17:47:40 1999h***************9*** 24,29 ****--- 24,32 ---- #include  #include y #include + #ifdef VMS+ #include + #endifR /* Not all systems declare ERRNO in errno.h... and some systems #define it! */ #if !defined (errno) extern int errno;E****************** 52,57 ****--- 55,64 ---- #include  #include "builtins/getopt.h" + #if defined (USE_VMS)+ #include "vmsutil.h" + #endif+ * /* The size that strings change by. */" #define DEFAULT_ARRAY_SIZE 512 *************** *** 1036,1041 ****--- 1043,1054 ----G perform quoted null character removal on the current word. */_* remove_quoted_nulls (current_word);B result = make_word_list (make_word (current_word), result);+ #if defined (USE_VMS)l+ /* expand each word */f.+ if ((!quoted && current_word[0] == '/')N+ || (quoted && current_word[0] == CTLESC && current_word[1] == '/'))%+ result->word->expansion = 1;o + #endif if (quoted)" result->word->quoted = 1; }***************e*** 1845,1850 ****--- 1858,1890 ---- nfifo = 0; } + #if defined (USE_VMS)l+ static char * + make_named_pipe ()+ {e+ char *tmpdir;i+ char *tname; + int fd; + !+ tmpdir = getenv ("TMPDIR");*+ if (tmpdir == NULL)+ tmpdir = "/tmp";+ ?+ tname = xmalloc (strlen (tmpdir) + sizeof ("/npXXXXXX"));i-+ sprintf (tname, "%s/npXXXXXX", tmpdir);o3+ tname = mktemp (vmsutil_expand_path (tname));)+ if ((fd = creat (tname, 0600)) < 0)= + { + free (tname);, + return ((char *)NULL); + }e + else+ close (fd);)+ + add_fifo_list (tname);+ return (tname);,+ }+ #else /* !USE_VMS */ static char *M make_named_pipe () {i***************e*** 1860,1865 ****--- 1900,1906 ---- add_fifo_list (tname); return (tname);u }e+ #endif /* !USE_VMS */u ! #if !defined (_POSIX_VERSION) int******************* 1875,1880 ****--- 1916,1931 ---- }=  #endif /* !_POSIX_VERSION */ + #if defined (VMS)+ int + mkfifo (path, mode) + char *path;+ int mode;+ {e+ return (-1);+ }_ + #endif+  #else /* HAVE_DEV_FD */d N /* DEV_FD_LIST is a bitmap of file descriptors attached to pipes the shell****************** 1985,1990 ****--- 2036,2044 ---- #if defined (JOB_CONTROL)n pid_t old_pipeline_pgrp;  #endif + #if defined (USE_VMS) + OLDENVBUF oldenvbuf; + #endif  if (!string || !*string) return ((char *)NULL);******************* 1992,1998 ****--- 2046,2056 ---- #if !defined (HAVE_DEV_FD)$ pathname = make_named_pipe (); #else /* HAVE_DEV_FD */t+ #if defined (USE_VMS)$+ if (vmsutil_pipe (fildes) < 0) + #else0 if (pipe (fildes) < 0) + #endif  {*J internal_error ("can't make pipes for process substitution: %s", strerror (errno)); ***************t*** 2030,2041 ****--- 2088,2108 ---- stop_making_children ();( pipeline_pgrp = old_pipeline_pgrp; #else /* !JOB_CONTROL */+ #if defined (USE_VMS)0+ vmsutil_save_all_environment (&oldenvbuf); + #endif) pid = make_child ((char *)NULL, 1);)+ #if defined (USE_VMS)+ if (pid > 0) + #elsef if (pid == 0) + #endif  {+ #if !defined (USE_VMS)( /* Cancel traps, in trap.c. */& restore_original_signals ();! setup_async_signals (); + #endif! subshell_environment++;e  } #endif /* !JOB_CONTROL */ ***************e*** 2049,2059 ****--- 2116,2136 ----! close (parent_pipe_fd);  close (child_pipe_fd); #endif /* HAVE_DEV_FD */+ #if defined (USE_VMS)_7+ vmsutil_restore_all_environment (&oldenvbuf); + #endif  return ((char *)NULL);  }  + #if defined (USE_VMS)*+ if (pid == 0)1 + {+ /* parent side */*$+ process_substitute_parent: + #elseh if (pid > 0)  {r + #endif" last_made_pid = old_pid; 4 #if defined (JOB_CONTROL) && defined (PGRP_PIPE)***************o*** 2080,2086 ****--- 2157,2168 ----  {rK internal_error ("cannot open named pipe %s for %s: %s", pathname, G open_for_read_in_child ? "reading" : "writing", strerror (errno));r+ #if defined (USE_VMS)r$+ vmsutil_wait_status = 127;'+ goto process_substitute_exit; + #else exit (127);I + #endif  }  #else /* HAVE_DEV_FD */ fd = child_pipe_fd;4***************4*** 2090,2096 ****--- 2172,2183 ----  {aH internal_error ("cannot duplicate named pipe %s as fd %d: %s",A pathname, open_for_read_in_child ? 0 : 1, strerror (errno));l+ #if defined (USE_VMS)$+ vmsutil_wait_status = 127;'+ goto process_substitute_exit;l + #else  exit (127);l + #endif  }(  close (fd);t******************* 2118,2125 ****--- 2205,2222 ----- close (open_for_read_in_child ? 0 : 1);S #endif /* !HAVE_DEV_FD */( + #if defined (USE_VMS)N#+ vmsutil_wait_status = result;+ + process_substitute_exit:3+ vmsutil_restore_all_environment (&oldenvbuf); + + /* run parent side */c%+ goto process_substitute_parent;* + #else5 exit (result); /*NOTREACHED*/ + #endif }K% #endif /* PROCESS_SUBSTITUTION */ ***************e*** 2135,2140 ****--- 2232,2241 ----# char *istring = (char *)NULL; - int istring_index, istring_size, c = 1;a int result;i+ #if defined (USE_VMS)%+ int pipes = vmsutil_pipe_no ();N+ OLDENVBUF oldenvbuf; + #endif ' istring_index = istring_size = 0;n ***************l*** 2144,2151 ****--- 2245,2260 ---- return ((char *)NULL); G /* Pipe the output of executing STRING into the current shell. */ + #if defined (USE_VMS)e$+ if (vmsutil_pipe (fildes) < 0) + #elseg if (pipe (fildes) < 0) + #endif  {t+ #if defined (USE_VMS)+ fildes[0] = -1;+ fildes[1] = -1;i + #endifH internal_error ("Can't make pipes for command substitution!"); goto error_exit;  } ***************(*** 2167,2178 ****--- 2276,2292 ----* pipeline_pgrp = old_pipeline_pgrp; }S #else /* !JOB_CONTROL */+ #if defined (USE_VMS)e0+ vmsutil_save_all_environment (&oldenvbuf); + #endif) pid = make_child ((char *)NULL, 0);* + #if !defined (USE_VMS) if (pid == 0)E /* Reset the signal handlers in the child, but don't free thei trap strings. */e! reset_signal_handlers ();e + #endif #endif /* !JOB_CONTROL */i  if (pid < 0)*************** *** 2180,2193 ****--- 2294,2329 ----L internal_error ("Can't make a child for command substitution: %s", strerror (errno));e error_exit:+ #if defined (USE_VMS)i7+ vmsutil_restore_all_environment (&oldenvbuf);l#+ error_exit_without_restore:r + #endif  FREE (istring);(+ #if defined (USE_VMS)e+ if (fildes[0] >= 0) + {+ close (fildes[0]);e+ fildes[0] = -1;+ }+ if (fildes[1] >= 0))+ {+ close (fildes[1]);7+ fildes[1] = -1;+ }%+ vmsutil_pipe_clean (pipes); + #elseS close (fildes[0]); close (fildes[1]); + #endif  return ((char *)NULL);  }v + #if defined (USE_VMS)+ if (pid > 0) + #elses if (pid == 0). + #endif  {u* set_sigint_handler (); /* XXX */ #if defined (JOB_CONTROL)1******************* 2198,2206 ****--- 2334,2348 ---- internal_error B ("command_substitute: cannot duplicate pipe as fd 1: %s", strerror (errno));+ #if defined (USE_VMS)a1+ vmsutil_wait_status = (EXECUTION_FAILURE); + goto error_exit;n + #elsee  exit (EXECUTION_FAILURE); + #endif } + #if !defined (USE_VMS)= /* If standard output is closed in the parent shell ; (such as after `exec >&-'), file descriptor 1 will be 9 the lowest available file descriptor, and end up inE***************2*** 2216,2221 ****--- 2358,2364 ----( (fildes[0] != fileno (stdout)) &&& (fildes[0] != fileno (stderr))) close (fildes[0]); + #endif A /* The currently executing shell is not interactive. */e interactive = 0;****************** 2229,2258 ****--- 2372,2435 ----+ so we don't go back up to main (). */ & result = setjmp (top_level); + #if defined (USE_VMS) !+ if (result == EXITPROG)+ {<+ vmsutil_wait_status = (last_command_exit_value) << 8;+ goto error_exit;+ }+ else if (result)+ {1+ vmsutil_wait_status = (EXECUTION_FAILURE);E+ goto error_exit; + }+ elseY+ vmsutil_wait_status = (parse_and_execute (string, "command substitution", -1)) << 8;t+ 7+ vmsutil_restore_all_environment (&oldenvbuf);"+ + /* run parent side */r)+ goto command_substitute_parent; + #else /* !USE_VMS */! if (result == EXITPROG)e$ exit (last_command_exit_value); else if (result) exit (EXECUTION_FAILURE); elseC exit (parse_and_execute (string, "command substitution", -1)); + #endif /* !USE_VMS */d  }  else  {( FILE *istream; + #if defined (USE_VMS) + command_substitute_parent:"+ /* reset file pointer */)+ lseek (fildes[0], 0, SEEK_SET);i,+ istream = fdopen (fildes[0], "r"); + #elsed, istream = fdopen (fildes[0], "r"); + #endif 4 #if defined (JOB_CONTROL) && defined (PGRP_PIPE) close_pgrp_pipe ();e) #endif /* JOB_CONTROL && PGRP_PIPE */e  close (fildes[1]);+ #if defined (USE_VMS) + fildes[1] = -1; + #endif  if (!istream)d {O internal_error ("Can't reopen pipe to command substitution (fd %d): %s",r$ fildes[0], strerror (errno));+ #if defined (USE_VMS)5'+ goto error_exit_without_restore; + #elseB goto error_exit;l + #endif } @ /* Read the output of the command through the pipe. */*************** *** 2283,2289 ****--- 2460,2472 ---- }  fclose (istream);2+ #if defined (USE_VMS) *+ /* fildes[0] closed by fclose */+ fildes[0] = -1;(%+ vmsutil_pipe_clean (pipes);i + #elseU close (fildes[0]); + #endif 3 last_command_exit_value = wait_for (pid);' last_command_subst_pid = pid;n***************r*** 2305,2311 ****--- 2488,2498 ----J /* If we read no output, just return now and save ourselves some trouble. */r! if (istring_index == 0)i+ #if defined (USE_VMS)!%+ goto error_exit_without_restore;S + #elsem goto error_exit;e + #endif G /* Strip trailing newlines from the output of the command. */U if (quoted) ****************** 2684,2689 ****--- 2871,2879 ----1 int number; /* Temporary number value. */p; int t_index; /* For calls to string_extract_xxx. */ K char *command_subst_result; /* For calls to command_substitute (). */e+ #if defined (USE_VMS) + int need_expand_path = 0;* + #endif  istring[0] = '\0'; ***************n*** 2797,2802 ****--- 2987,2997 ----  temp = itos (number); dollar_add_string:( if (string[sindex]) sindex++;+ #if defined (USE_VMS))+ if (temp && istring_index == 0E+ && (temp[0] == '/' || (temp[0] == CTLESC && temp[1] == '/'))) + need_expand_path = 1; + #endif % /* Add TEMP to ISTRING. */i add_string:*************** *** 3270,3275 ****--- 3465,3474 ----8 if (var && !invisible_p (var) && value_cell (var))  {0" temp = value_cell (var);+ #if defined (USE_VMS)n+ if (temp[0] == '/')p!+ need_expand_path = 1;o + #endif> temp = quoted && temp && *temp ? quote_string (temp)$ : quote_escapes (temp); free (name);***************s*** 3308,3316 ****--- 3507,3522 ----# handle_command_substitution: B command_subst_result = command_substitute (temp, quoted); K+ #if 0 /* unwind_frame_run_internal may have already freed temp. DBR. */r FREE (temp);a + #endif % temp = command_subst_result;i+ #if defined (USE_VMS)e'+ if (temp && istring_index == 0 C+ && (temp[0] == '/' || (temp[0] == CTLESC && temp[1] == '/')))x + need_expand_path = 1; + #endif  if (string[sindex]) sindex++;***************2*** 3362,3367 ****--- 3568,3577 ----  t_index = sindex;? temp = string_extract_double_quoted (string, &sindex);N+ #if defined (USE_VMS) :+ if (temp && istring_index == 0 && temp[0] == '/') + need_expand_path = 1; + #endif @ /* If the quotes surrounded the entire string, then the% whole word was quoted. */ *************** *** 3437,3442 ****--- 3647,3656 ----9 as well), so we go directly to add_string. */ if (tresult)  {+ #if defined (USE_VMS) #+ if (tresult->word->expansion)1+ need_expand_path = 1; + #endif if (tresult->next)  {e quote_list (tresult);u*************** *** 3527,3532 ****--- 3741,3750 ----  }  add_character:5+ #if defined (USE_VMS)-*+ if (istring_index == 0 && c == '/')+ need_expand_path = 1; + #endif- if (istring_index + 1 >= istring_size)V  {4 while (istring_index + 1 >= istring_size)****************** 3543,3548 ****--- 3761,3792 ----  finished_with_string: final_exit:s+ #if defined (USE_VMS) N+ if (need_expand_path != 0 && istring && strpbrk (istring, ":;") == NULL) + {e)+ char tbuf[4] = { 0, 0, 0, 0, }; '+ char *p = istring, *q = tbuf; + int i;+ + /* dequote 4 chars */s!+ for (i = 0; i < 4; i++)e+ {+ if (*p == CTLESC) + p++;(+ if (*p == '\0')+ break;e+ *q++ = *p++; + }+ 0+ /* check whether it's option switch */W+ if (tbuf[0] != '/' || (tbuf[1] != '\0' && (tbuf[1] == '/' || tbuf[2] == '\0')i4+ && (tbuf[1] != '/' || !isalpha (tbuf[2])2+ || (tbuf[3] != '/' && tbuf[3] != '\0'))))+ need_expand_path = 0; + }0 + else+ need_expand_path = 0; + #endifD /* OK, we're ready to return. If we have a quoted string, andJ quoted_dollar_at is not set, we do no splitting at all; otherwiseJ we split on ' '. The routines that call this will handle what to****************** 3625,3630 ****--- 3869,3877 ----A temp_list = make_word_list (tword, (WORD_LIST *)NULL);eE tword->quoted = quoted || (quoted_state == WHOLLY_QUOTED); 0 tword->assignment = word->assignment;+ #if defined (USE_VMS)/+ tword->expansion = need_expand_path; + #endif  } } ***************;*** 4497,4502 ****--- 4744,4756 ---- void sv_notify ();  #endif + #if defined (USE_VMS)%+ void sv_path_expand (char *name);e(+ void sv_path_separator (char *name);$+ void sv_path_slash (char *name);!+ void sv_sysroot (char *name); + #endif+ I #define SET_INT_VAR(name, intvar) intvar = find_variable (name) != 0t  struct name_and_function {***************r*** 4549,4554 ****--- 4803,4816 ----D { "allow_null_glob_expansion", sv_allow_null_glob_expansion },$ { "noclobber", sv_noclobber },  { "nolinks", sv_nolinks },+ + #if defined (USE_VMS)(+ { "PATH_EXPAND", sv_path_expand },.+ { "PATH_SEPARATOR", sv_path_separator },&+ { "PATH_SLASH", sv_path_slash }, + { "SYSROOT", sv_sysroot }, + #endif+ ) { (char *)0x00, (VFunction *)0x00 } }; ***************d*** 4865,4867 ****--- 5127,5209 ----2 posix_readline_initialize (posixly_correct); #endif /* READLINE */  }c+ + #if defined (USE_VMS)n+ void+ sv_path_expand (char *name)+ {*+ char *p;+ "+ p = get_string_value (name);+ vmsutil_path_expand = 0;+ if (p != NULL) + {t%+ if (*p == 'y' || *p == 'Y') + vmsutil_path_expand = 1;t + }G+ } + + void"+ sv_path_separator (char *name)+ {<+ char **vp, *p;+ ++ vp = vmsutil_get_import_variables ();{"+ p = get_string_value (name);#+ vmsutil_path_separator = ';';x+ if (p != NULL) + { A+ if (*p != '\0' && *p != '/' && *p != '\\' && *p < 0x7f)u9+ vmsutil_path_separator = (int) *(unsigned char *) p;i + }l(+ vmsutil_put_export_variables (vp);+ }r+ + void+ sv_path_slash (char *name)+ { + char **vp, *p;+ ++ vp = vmsutil_get_import_variables ();n"+ p = get_string_value (name);+ vmsutil_path_slash = '/';U+ if (p != NULL) + {pC+ if (*p != '\0' && (*p == '/' || *p == '\\') && *p < 0x7f)/5+ vmsutil_path_slash = (int) *(unsigned char *) p; + }*(+ vmsutil_put_export_variables (vp);+ }o+ + void+ sv_sysroot (char *name)f+ {n+ char **vp, *p;+ ++ vp = vmsutil_get_import_variables ();d"+ p = get_string_value (name);+ if (p != NULL) + {s\+ if (p[0] == '/' && p[1] == '/' && isalpha (p[2]) && (p[3] == '\0' || p[3] == '/'))+ {!+ vmsutil_sysroot[0] = p[2];T + vmsutil_sysroot[1] = ':';++ strcpy (vmsutil_sysroot + 2, p + 3);V+ }+ else!+ strcpy (vmsutil_sysroot, p); ,+ vmsutil_toslash (vmsutil_sysroot);F+ if (vmsutil_sysroot[0] != '/' || vmsutil_sysroot[1] != '\0')(+ vmsutil_delslash (vmsutil_sysroot);H+ if (isalpha (vmsutil_sysroot[0]) && vmsutil_sysroot[1] == ':')7+ vmsutil_sysroot[0] = tolower (vmsutil_sysroot[0]);*9+ vmsutil_sysroot_len = strlen (vmsutil_sysroot);* + } + else + {$+ vmsutil_sysroot[0] = '\0';#+ vmsutil_sysroot_len = -1;e + }V(+ vmsutil_put_export_variables (vp);+ } + #endifKdiff -r -c bash-1_14_7/support/getcppsyms.c bash1147/support/getcppsyms.c ?*** bash-1_14_7/support/getcppsyms.c Wed Mar 10 09:44:07 1999_<--- bash1147/support/getcppsyms.c Wed Mar 10 09:45:24 1999******************* 422,427 ****--- 422,430 ---- #if defined (vax)I printf (" -Dvax"); #endif /* vax */+ #if defined (vms)u+ printf (" -Dvms");+ #endif /* vms */  printf ("\n"); exit (0);tAdiff -r -c bash-1_14_7/support/inpath. bash1147/support/inpath.:*** bash-1_14_7/support/inpath. Wed Mar 10 09:44:07 19997--- bash1147/support/inpath. Wed Mar 10 09:45:24 1999****************8*** 3,18 ****1H # Search $PATH for a file the same name as $1; return TRUE if found. #;  command=$1 [ -n "$command" ] || exit 1* #! set `echo $PATH | sed 's/^:/.:/n! s/::/:.:/ge! s/:$/:./ ! s/:/ /g'` d while [ $# -ne 0 ] ; dof9 [ -f $1/$command ] && exit 0 # test -x not universal  shift done --- 3,23 ----H # Search $PATH for a file the same name as $1; return TRUE if found. #n + PSC=$PATH_SEPARATORe+ if [ -z "$PSC" ]; then + PSC=";"t+ fi command=$1 [ -n "$command" ] || exit 1= ,! set `echo $PATH | sed -e "s/^$PSC/.$PSC/! s/$PSC$PSC/$PSC.$PSC/g ! s/$PSC\\$/$PSC./R#! s/$PSC/ /g" -e 's,\\\\,/,g'`* * while [ $# -ne 0 ] ; do9 [ -f $1/$command ] && exit 0 # test -x not universalv?+ [ -f $1/${command}.exe ] && exit 0 # test -x not universal  shift done /diff -r -c bash-1_14_7/test.c bash1147/test.ce1*** bash-1_14_7/test.c Wed Mar 10 09:43:49 1999e.--- bash1147/test.c Fri Mar 19 17:36:16 1999***************p*** 27,32 ****--- 27,36 ---- #include  #include "bashtypes.h" + #if defined (VMS)m+ #define lstat stat + #endif+  #if !defined (STANDALONE)e# # if !defined (_POSIX_VERSION)n # include l***************B*** 47,52 ****--- 51,60 ----( # define digit_value(c) ((c) - '0') #endif /* STANDALONE */U + #if defined (USE_VMS)t+ #include & + #endif+  #if !defined (STRLEN)pN # define STRLEN(s) ((s)[0] ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)  #endif***************n*** 191,197 ****--- 199,217 ---- }  }8 #endif /* !HAVE_DEV_FD */d+ #if defined (USE_VMS) + {e+ int rc;t+ char *fixp;N+ 7+ fixp = vmsutil_expand_path (savestring (path));x + rc = stat (fixp, finfo);+ free (fixp);+ return rc;+ } + #elseq" return (stat (path, finfo)); + #endif }  K /* Do the same thing access(2) does, but use the effective uid and gid,3*************** *** 773,778 ****--- 793,822 ----- case 'x': /* File is executable? */ unary_advance ();6 value = -1 != EACCESS (argv[pos - 1], X_OK);+ #if defined (USE_VMS) + if (value != TRUE)+ {+ char *name, *ext;+ int len;*+ $+ len = strlen (argv[pos - 1]);+ name = malloc (len + 5);c+ if (name != NULL) + {(+ strcpy (name, argv[pos - 1]);+ ext = name + len;+ #if defined (USE_VMS) <+ while (vmsutil_add_executable_suffix (name, ext)) + #endif+ { ++ value = -1 != EACCESS (name, X_OK); + if (value == TRUE)+ break;+ }d+ free (name);_ + }+ } + #endif! return (TRUE == value);  / case 'O': /* File is owned by you? */ Cdiff -r -c bash-1_14_7/tests/exp-tests. bash1147/tests/exp-tests.s;*** bash-1_14_7/tests/exp-tests. Wed Mar 10 09:44:08 1999o8--- bash1147/tests/exp-tests. Wed Mar 10 09:45:26 1999***************C*** 18,35 ****O # Test the substitution quoting characters (CTLESC and CTLNUL) in different  # combinations ! expect "<^A>"c! recho `echo ''`! expect "<^A>"u! recho `echo ""`! expect "<^B>"]! recho `echo ''`! expect "<^B>"'! recho `echo ""`! expect "<^A>"[! recho `echo `! expect "<^B>"n! recho `echo ` 2 # Test null strings without variable expansion expect ""w--- 18,35 ----O # Test the substitution quoting characters (CTLESC and CTLNUL) in different  # combinations ! #expect "<^A>"! #recho `echo ''`e! #expect "<^A>"! #recho `echo ""`*! #expect "<^B>"! #recho `echo ''`8! #expect "<^B>"! #recho `echo ""`o! #expect "<^A>"! #recho `echo ` ! #expect "<^B>"! #recho `echo `s 2 # Test null strings without variable expansion expect "" ****************** 227,237 **** expect '<\$x>' recho '\$x'd ! expect '<$x>'! recho `echo '\$x'` ! expect '<\$x>'! recho $(echo '\$x')d - # The difference between $* "$*" and "$@"E --- 227,237 ---- expect '<\$x>' recho '\$x'h ! #expect '<$x>'! #recho `echo '\$x'`h ! #expect '<\$x>'r! #recho $(echo '\$x') - # The difference between $* "$*" and "$@"t ***************)*** 316,323 **** expect '<26>'i recho $[ 13 * 2 ]r ! expect '<\>'! recho `echo \\\\`  expect '<~>'  recho '~'l--- 316,323 ---- expect '<26>'c recho $[ 13 * 2 ], ! #expect '<\>'o! #recho `echo \\\\`  expect '<~>'  recho '~'DKdiff -r -c bash-1_14_7/tests/run-ifs-tests. bash1147/tests/run-ifs-tests. ?*** bash-1_14_7/tests/run-ifs-tests. Wed Mar 10 09:44:10 1999<--- bash1147/tests/run-ifs-tests. Wed Mar 10 09:45:28 1999******************* 2,13 *****? # show that IFS is only applied to the result of expansionsi #p ../bash ifs-test-1.sh > xx! diff xx ./ifs.1.right  ../bash ifs-test-2.sh > xx! diff xx ./ifs.2.righta  ../bash ifs-test-3.sh > xx! diff xx ./ifs.3.righta  rm -f xx--- 2,13 ----? # show that IFS is only applied to the result of expansions= # ../bash ifs-test-1.sh > xx! diff xx ./ifs_1.right  ../bash ifs-test-2.sh > xx! diff xx ./ifs_2.rightv  ../bash ifs-test-3.sh > xx! diff xx ./ifs_3.right   rm -f xxAdiff -r -c bash-1_14_7/tests/varenv.sh bash1147/tests/varenv.sh):*** bash-1_14_7/tests/varenv.sh Wed Mar 10 09:44:11 19997--- bash1147/tests/varenv.sh Wed Mar 10 09:45:29 1999 ***************p*** 45,51 **** echo $HOME  expect $HOME! HOME=/a/b/c /bin/echo $HOMEt  expect $HOME echo $HOME--- 45,51 ---- echo $HOME  expect $HOME#! HOME=/a/b/c /gnu/bin/echo $HOMEe  expect $HOME echo $HOME****************** 59,65 ****, # This should echo $HOME 9, NOT /a/b/c 9  expect "$HOME"#! HOME=/a/b/c /bin/echo $HOME c=9a expect "$HOME 7" echo $HOME $cx --- 59,65 ----, # This should echo $HOME 9, NOT /a/b/c 9  expect "$HOME"'! HOME=/a/b/c /gnu/bin/echo $HOME c=9p expect "$HOME 7" echo $HOME $cv /diff -r -c bash-1_14_7/trap.c bash1147/trap.c 1*** bash-1_14_7/trap.c Wed Mar 10 09:43:49 1999&.--- bash1147/trap.c Fri Mar 19 17:36:16 1999*************** *** 86,97 ****--- 86,99 ----8 original_signals[i] = IMPOSSIBLE_TRAP_HANDLER;  }  + #if !defined (USE_VMS)B /* Show which signals are treated specially by the shell. */ #if defined (SIGCHLD) W original_signals[SIGCHLD] = (SigHandler *) set_signal_handler (SIGCHLD, SIG_DFL);s> set_signal_handler (SIGCHLD, original_signals[SIGCHLD]);7 sigmodes[SIGCHLD] |= (SIG_SPECIAL | SIG_NO_TRAP);  #endif /* SIGCHLD */+ #endif /* !USE_VMS */  original_signals[SIGINT] =< (SigHandler *) set_signal_handler (SIGINT, SIG_DFL);***************V*** 454,459 ****--- 456,483 ----I /* Handle the calling of "trap 0". The only sticky situation is when1J the command to be executed includes an "exit". This is why we have< to provide our own place for top_level to jump to. */+ #if defined (USE_VMS)*"+ /* static variables wrapper */+ int-&+ vmsutil_get_signal_modes (int sig)+ {"!+ if (sig < 0 || sig >= NSIG)e+ return -1;+ return sigmodes[sig];f+ } + + int 1+ vmsutil_set_signal_modes (int sig, int modes)-+ {s+ int oldmodes;4!+ if (sig < 0 || sig >= NSIG)_+ return -1;+ oldmodes = sigmodes[sig];h+ sigmodes[sig] = modes;+ return oldmodes;+ }* + #endif+  int  run_exit_trap () { ***************t*** 586,591 ****--- 610,619 ---- {1$ char *command, *saved_command; int old_exit_value;e+ #if defined (USE_VMS).$+ int old_subshell_exit_builtin;'+ extern int subshell_exit_builtin; + #endif L /* Run the interrupt trap if SIGINT is trapped and not ignored, and ifG we are not currently running in the interrupt trap handler. */i****************** 601,608 ****--- 629,643 ----/ command = savestring (saved_command);m 3 old_exit_value = last_command_exit_value;h+ #if defined (USE_VMS)$=+ old_subshell_exit_builtin = subshell_exit_builtin; $+ subshell_exit_builtin = 0; + #endif; parse_and_execute (command, "interrupt trap", 0); 3 last_command_exit_value = old_exit_value; + #if defined (USE_VMS)v<+ subshell_exit_builtin = old_subshell_exit_builtin; + #endif . sigmodes[SIGINT] &= ~SIG_INPROGRESS; /diff -r -c bash-1_14_7/trap.h bash1147/trap.h91*** bash-1_14_7/trap.h Wed Mar 10 09:43:49 1999 .--- bash1147/trap.h Wed Mar 10 09:44:58 1999*************** *** 29,35 ****--- 29,39 ---- #endif /* SIG_DFL */  #if !defined (NSIG)+ #if defined (SIGMAX)+ #define NSIG SIGMAXu + #elsee #define NSIG 64*+ #endif /* !SIGMAX */ #endif /* !NSIG */  #define NO_SIG -1)9diff -r -c bash-1_14_7/variables.c bash1147/variables.cV6*** bash-1_14_7/variables.c Wed Mar 10 09:43:49 19993--- bash1147/variables.c Fri Mar 19 17:36:16 1999 *************** *** 195,201 ****--- 195,211 ----9 temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE);! set_auto_export (temp_var);H + #if defined (USE_VMS)U(+ temp_var = find_variable ("TERM");+ if (!temp_var) + {i.+ /* makes empty invisible variable */;+ temp_var = bind_variable ("TERM", (char *) NULL); 0+ temp_var->attributes |= att_invisible; + } + #else- temp_var = set_if_not ("TERM", "dumb");g + #endif! set_auto_export (temp_var);g  if (interactive_shell)***************,*** 537,544 ****--- 547,562 ---- register SHELL_VAR *var; / for (i = 0; list && (var = list[i]); i++)o+ #if defined (USE_VMS)i + {S+ QUIT;(!+ if (!invisible_p (var)) #+ print_assignment (var); + }= + #elseg if (!invisible_p (var))c! print_assignment (var);L + #endif }   #if defined (NOTDEF)***************t*** 1666,1676 ****--- 1684,1700 ---- { free (array[i]);c& array[i] = savestring (assign);+ #if defined (USE_VMS)12+ array[i] = vmsutil_fix_variable (array[i]); + #endif return (array); }  }_E array = (char **)xrealloc (array, ((2 + i) * sizeof (char *)));' array[i++] = savestring (assign);b+ #if defined (USE_VMS)s5+ array[i-1] = vmsutil_fix_variable (array[i-1]); + #endif array[i] = (char *)NULL; return (array);a }t