From dab0a3eda989972d4df8e08cc1b7d68422652e61 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Sat, 30 Sep 2023 21:57:19 -0300 Subject: [PATCH] Attempt to fix `Error: Invalid option: -noninteractive`. Hopefully fixes #305 --- src/gsudo/Helpers/CommandLineParser.cs | 1 + src/gsudo/Helpers/CommandToRunAdapter.cs | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gsudo/Helpers/CommandLineParser.cs b/src/gsudo/Helpers/CommandLineParser.cs index 5f1de791..5bc10b94 100644 --- a/src/gsudo/Helpers/CommandLineParser.cs +++ b/src/gsudo/Helpers/CommandLineParser.cs @@ -79,6 +79,7 @@ private ICommand ParseOptions() if (c != null) return c; } + else if (arg.In("-noninteractive")) { } // ignore due to gerardog/gsudo#305 else if (arg.StartsWith("-", StringComparison.OrdinalIgnoreCase) && arg.NotIn("-encodedCommand")) // -encodedCommand is not posix compliant, but is what powershell sends on: gsudo { script block } // So treat -encodedCommand as part of the CommandToRun, for gerardog/gsudo#160 diff --git a/src/gsudo/Helpers/CommandToRunAdapter.cs b/src/gsudo/Helpers/CommandToRunAdapter.cs index bdb5ef67..99968b03 100644 --- a/src/gsudo/Helpers/CommandToRunAdapter.cs +++ b/src/gsudo/Helpers/CommandToRunAdapter.cs @@ -1,15 +1,12 @@ using gsudo.Native; -using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Security.AccessControl; using System.Security.Principal; using System.Text; -using System.Threading.Tasks; namespace gsudo.Helpers { @@ -133,7 +130,7 @@ Running ./gsudo {command} should elevate the powershell command. if (!Settings.PowerShellLoadProfile) newArgs.Add("-NoProfile"); - if (args[0] == "-encodedCommand") + if (args[0].In("-encodedCommand", "-noninteractive")) { newArgs.AddRange(args); }