Quellcode durchsuchen

Shell: Don't execute scripts interactively.

The following example should illustrate one issue arising from this:

    $ echo 'exit 1' > example.sh
    $ Shell example.sh
    Good-bye!

This message is meant to be shown to an interactive user, but not in a
shell script.
asynts vor 4 Jahren
Ursprung
Commit
afa2523724
1 geänderte Dateien mit 2 neuen und 0 gelöschten Zeilen
  1. 2 0
      Shell/Shell.cpp

+ 2 - 0
Shell/Shell.cpp

@@ -873,6 +873,8 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
 bool Shell::run_file(const String& filename, bool explicitly_invoked)
 bool Shell::run_file(const String& filename, bool explicitly_invoked)
 {
 {
     TemporaryChange script_change { current_script, filename };
     TemporaryChange script_change { current_script, filename };
+    TemporaryChange interactive_change { m_is_interactive, false };
+
     auto file_result = Core::File::open(filename, Core::File::ReadOnly);
     auto file_result = Core::File::open(filename, Core::File::ReadOnly);
     if (file_result.is_error()) {
     if (file_result.is_error()) {
         if (explicitly_invoked)
         if (explicitly_invoked)