Explorar el Código

Shell: Set subshell flag after checking for its value in parent shell

This also reverts commit 07cc7eed295a29afef37c4bfaabaf57a3f4af0c1, as
that attempted to fix the issue this caused (and succeeded...but it
broke something else on linux).
Ali Mohammad Pur hace 3 años
padre
commit
7ac8bd44f8
Se han modificado 1 ficheros con 2 adiciones y 4 borrados
  1. 2 4
      Userland/Shell/Shell.cpp

+ 2 - 4
Userland/Shell/Shell.cpp

@@ -568,12 +568,9 @@ int Shell::run_command(StringView cmd, Optional<SourcePosition> source_position_
     }
     }
 
 
     tcgetattr(0, &termios);
     tcgetattr(0, &termios);
-    tcsetattr(0, TCSANOW, &default_termios);
 
 
     (void)command->run(*this);
     (void)command->run(*this);
 
 
-    tcsetattr(0, TCSANOW, &termios);
-
     if (!has_error(ShellError::None)) {
     if (!has_error(ShellError::None)) {
         possibly_print_error();
         possibly_print_error();
         take_error();
         take_error();
@@ -743,7 +740,6 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
     if (child == 0) {
     if (child == 0) {
         close(sync_pipe[1]);
         close(sync_pipe[1]);
 
 
-        m_is_subshell = true;
         m_pid = getpid();
         m_pid = getpid();
         Core::EventLoop::notify_forked(Core::EventLoop::ForkEvent::Child);
         Core::EventLoop::notify_forked(Core::EventLoop::ForkEvent::Child);
         TemporaryChange signal_handler_install { m_should_reinstall_signal_handlers, true };
         TemporaryChange signal_handler_install { m_should_reinstall_signal_handlers, true };
@@ -769,6 +765,8 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
         if (!m_is_subshell && command.should_wait)
         if (!m_is_subshell && command.should_wait)
             tcsetattr(0, TCSANOW, &default_termios);
             tcsetattr(0, TCSANOW, &default_termios);
 
 
+        m_is_subshell = true;
+
         if (command.should_immediately_execute_next) {
         if (command.should_immediately_execute_next) {
             VERIFY(command.argv.is_empty());
             VERIFY(command.argv.is_empty());