Merge pull request #2264 from Skgland/fix-os-argv-1

Fix os:argv/1 in case the raw args contain multiple `--`
This commit is contained in:
Mark Thom
2024-01-06 15:52:53 -07:00
committed by GitHub
9 changed files with 32 additions and 3 deletions

View File

@@ -138,7 +138,8 @@ raw_argv(Argv) :-
argv(Argv) :- argv(Argv) :-
can_be(list, Argv), can_be(list, Argv),
'$argv'(Argv0), '$argv'(Argv0),
( append(_, ["--"|Argv], Argv0) -> ( append(_, ["--"|Argv1], Argv0) ->
true Argv = Argv1
; Argv = [] ;
Argv = []
). ).

View File

@@ -0,0 +1,6 @@
os:argv(V).
os:argv(["test1"|_]).
os:argv(["--"|_]).
os:argv([V, "--"|_]).
os:argv(["test2"|_]).
os:argv([]).

View File

@@ -0,0 +1,6 @@
V = ["test1","--","test2"].
true.
false.
V = "test1".
false.
false.

View File

@@ -0,0 +1,2 @@
# https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820
args = ["-f", "--no-add-history", "--", "test1", "--", "test2"]

View File

View File

@@ -0,0 +1,6 @@
os:argv(V).
os:argv(["test1"|_]).
os:argv(["--"|_]).
os:argv([V, "--"|_]).
os:argv(["test2"|_]).
os:argv([]).

View File

@@ -0,0 +1,6 @@
V = ["test1","--","test2","--"].
true.
false.
V = "test1".
false.
false.

View File

@@ -0,0 +1,2 @@
# https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820
args = ["-f", "--no-add-history", "--", "test1", "--", "test2", "--"]