• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision4142 (tree)
Time2020-11-05 20:58:03
Authormagicant

Log Message

Run redirections w/o command name in subshell (#39287, #40842)

Change Summary

Incremental Difference

--- yash/trunk/exec.c (revision 4141)
+++ yash/trunk/exec.c (revision 4142)
@@ -698,18 +698,26 @@
698698 return !is_interactive_now;
699699 }
700700
701- /* open redirections */
701+ /* done? */
702+ if (c->c_redirs == NULL) {
703+ laststatus = lastcmdsubstatus;
704+ return false;
705+ }
706+
707+ /* create a subshell to perform redirections in */
708+ fork_and_wait_T faw = fork_and_wait(0);
709+ if (faw.cpid != 0) {
710+ /* parent process */
711+ if (faw.namep != NULL)
712+ *faw.namep = command_to_wcs(c, false);
713+ return false;
714+ }
715+
716+ /* open redirections in subshell */
702717 savefd_T *savefd;
703718 ok = open_redirections(c->c_redirs, &savefd);
704719 undo_redirections(savefd);
705- if (ok) {
706- laststatus = lastcmdsubstatus;
707- } else {
708- laststatus = Exit_REDIRERR;
709- apply_errexit_errreturn(NULL);
710- }
711-
712- return false;
720+ exit_shell_with_status(ok ? lastcmdsubstatus : Exit_REDIRERR);
713721 }
714722
715723 /* Executes the simple command that has one or more expanded words.
Show on old repository browser