Skip to content

Commit

Permalink
Merge pull request #306 from gerardog/fix/pwsh-noninteractive
Browse files Browse the repository at this point in the history
Fix `Error: Invalid option: -noninteractive` using `gsudo {command}` on Visual Studio code
  • Loading branch information
gerardog authored Dec 18, 2023
2 parents 49446f9 + 848d66d commit 71d84a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/gsudo/Helpers/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/gsudo/Helpers/CommandToRunAdapter.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 71d84a1

Please sign in to comment.