1
0
Эх сурвалжийг харах

When using a scripting console interactively, not warning about opening a session from a command-line or using a stored site

Source commit: be2b4d46dd2230a7e8b4f07f35274c0551c9bfdd
Martin Prikryl 6 жил өмнө
parent
commit
4c0917b517

+ 2 - 1
source/core/Script.cpp

@@ -310,6 +310,7 @@ __fastcall TScript::TScript(bool LimitedOutput)
   FTerminal = NULL;
   FGroups = false;
   FWantsProgress = false;
+  FInteractive = false;
   FIncludeFileMaskOptionUsed = false;
   FPendingLogLines = new TStringList();
 
@@ -2666,7 +2667,7 @@ void __fastcall TManagementScript::Connect(const UnicodeString Session,
         TScriptCommands::CheckParams(Options, false);
       }
 
-      if (!Session.IsEmpty() && !Data->Name.IsEmpty() && (Batch != TScript::BatchOff))
+      if (!Session.IsEmpty() && !Data->Name.IsEmpty() && (Batch != TScript::BatchOff) && !Interactive)
       {
         std::unique_ptr<TSessionData> DataWithFingerprint(Data->Clone());
         DataWithFingerprint->LookupLastFingerprint();

+ 2 - 0
source/core/Script.h

@@ -75,6 +75,7 @@ public:
   __property TTerminal * Terminal = { read = FTerminal };
   __property bool Groups = { read = FGroups, write = FGroups };
   __property bool WantsProgress = { read = FWantsProgress, write = FWantsProgress };
+  __property bool Interactive = { read = FInteractive, write = FInteractive };
 
 protected:
   TTerminal * FTerminal;
@@ -101,6 +102,7 @@ protected:
   int FInteractiveSessionReopenTimeout;
   bool FGroups;
   bool FWantsProgress;
+  bool FInteractive;
   TStrings * FPendingLogLines;
   bool FWarnNonDefaultCopyParam;
   bool FWarnNonDefaultSynchronizeParams;

+ 27 - 1
source/windows/ConsoleRunner.cpp

@@ -60,6 +60,7 @@ public:
   virtual bool __fastcall LimitedOutput();
   virtual bool __fastcall LiveOutput();
   virtual bool __fastcall NoInteractiveInput();
+  virtual bool __fastcall Interactive();
   virtual void __fastcall WaitBeforeExit();
   virtual bool __fastcall CommandLineOnly();
   virtual bool __fastcall WantsProgress();
@@ -478,6 +479,11 @@ bool __fastcall TOwnConsole::NoInteractiveInput()
   return false;
 }
 //---------------------------------------------------------------------------
+bool __fastcall TOwnConsole::Interactive()
+{
+  return true;
+}
+//---------------------------------------------------------------------------
 void __fastcall TOwnConsole::WaitBeforeExit()
 {
   unsigned long Read;
@@ -534,6 +540,7 @@ public:
   virtual bool __fastcall LiveOutput();
   virtual bool __fastcall NoInteractiveInput();
   virtual void __fastcall WaitBeforeExit();
+  virtual bool __fastcall Interactive();
   virtual bool __fastcall CommandLineOnly();
   virtual bool __fastcall WantsProgress();
   virtual void __fastcall Progress(TScriptProgress & Progress);
@@ -550,6 +557,7 @@ private:
   bool FPipeOutput;
   bool FNoInteractiveInput;
   bool FWantsProgress;
+  bool FInteractive;
   unsigned int FMaxSend;
 
   inline TConsoleCommStruct * __fastcall GetCommStruct();
@@ -831,6 +839,9 @@ void __fastcall TExternalConsole::Init()
       (CommStruct->InitEvent.OutputType != FILE_TYPE_DISK) &&
       (CommStruct->InitEvent.OutputType != FILE_TYPE_PIPE);
     FPipeOutput = (CommStruct->InitEvent.OutputType != FILE_TYPE_PIPE);
+    FInteractive =
+      (CommStruct->InitEvent.InputType != FILE_TYPE_DISK) &&
+      (CommStruct->InitEvent.InputType != FILE_TYPE_PIPE);
     FWantsProgress = CommStruct->InitEvent.WantsProgress;
   }
   __finally
@@ -854,6 +865,11 @@ bool __fastcall TExternalConsole::NoInteractiveInput()
   return FNoInteractiveInput;
 }
 //---------------------------------------------------------------------------
+bool __fastcall TExternalConsole::Interactive()
+{
+  return FInteractive;
+}
+//---------------------------------------------------------------------------
 void __fastcall TExternalConsole::WaitBeforeExit()
 {
   // noop
@@ -950,6 +966,7 @@ public:
   virtual bool __fastcall LimitedOutput();
   virtual bool __fastcall LiveOutput();
   virtual bool __fastcall NoInteractiveInput();
+  virtual bool __fastcall Interactive();
   virtual void __fastcall WaitBeforeExit();
   virtual bool __fastcall CommandLineOnly();
 
@@ -1017,6 +1034,11 @@ bool __fastcall TNullConsole::NoInteractiveInput()
   return true;
 }
 //---------------------------------------------------------------------------
+bool __fastcall TNullConsole::Interactive()
+{
+  return false;
+}
+//---------------------------------------------------------------------------
 void __fastcall TNullConsole::WaitBeforeExit()
 {
   DebugFail();
@@ -1994,6 +2016,7 @@ int __fastcall TConsoleRunner::Run(const UnicodeString Session, TOptions * Optio
       FScript->OnQueryCancel = ScriptQueryCancel;
       FScript->OnSynchronizeStartStop = ScriptSynchronizeStartStop;
       FScript->OnProgress = ScriptProgress;
+      FScript->Interactive = (ScriptCommands == NULL) && FConsole->Interactive();
 
       UpdateTitle();
 
@@ -2003,7 +2026,10 @@ int __fastcall TConsoleRunner::Run(const UnicodeString Session, TOptions * Optio
 
       if (!Session.IsEmpty())
       {
-        PrintMessage(LoadStr(SCRIPT_CMDLINE_SESSION));
+        if (!FScript->Interactive)
+        {
+          PrintMessage(LoadStr(SCRIPT_CMDLINE_SESSION));
+        }
         FCommandError = false;
         FScript->Connect(Session, Options, false);
         if (FCommandError)

+ 1 - 0
source/windows/WinInterface.h

@@ -625,6 +625,7 @@ public:
   virtual bool __fastcall LimitedOutput() = 0;
   virtual bool __fastcall LiveOutput() = 0;
   virtual bool __fastcall NoInteractiveInput() = 0;
+  virtual bool __fastcall Interactive() = 0;
   virtual void __fastcall WaitBeforeExit() = 0;
   virtual bool __fastcall CommandLineOnly() = 0;
   virtual bool __fastcall WantsProgress() = 0;