Skip to content

Commit

Permalink
Merge pull request mthom#2264 from Skgland/fix-os-argv-1
Browse files Browse the repository at this point in the history
Fix os:argv/1 in case the raw args contain multiple `--`
  • Loading branch information
mthom authored Jan 6, 2024
2 parents ed92e1b + 78b83ca commit 92b85d4
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/os.pl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
argv(Argv) :-
can_be(list, Argv),
'$argv'(Argv0),
( append(_, ["--"|Argv], Argv0) ->
true
; Argv = []
( append(_, ["--"|Argv1], Argv0) ->
Argv = Argv1
;
Argv = []
).
Empty file.
6 changes: 6 additions & 0 deletions tests/scryer/cli/issues/os_argv-no-final--.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
os:argv(V).
os:argv(["test1"|_]).
os:argv(["--"|_]).
os:argv([V, "--"|_]).
os:argv(["test2"|_]).
os:argv([]).
6 changes: 6 additions & 0 deletions tests/scryer/cli/issues/os_argv-no-final--.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
V = ["test1","--","test2"].
true.
false.
V = "test1".
false.
false.
2 changes: 2 additions & 0 deletions tests/scryer/cli/issues/os_argv-no-final--.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820
args = ["-f", "--no-add-history", "--", "test1", "--", "test2"]
Empty file.
6 changes: 6 additions & 0 deletions tests/scryer/cli/issues/os_argv.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
os:argv(V).
os:argv(["test1"|_]).
os:argv(["--"|_]).
os:argv([V, "--"|_]).
os:argv(["test2"|_]).
os:argv([]).
6 changes: 6 additions & 0 deletions tests/scryer/cli/issues/os_argv.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
V = ["test1","--","test2","--"].
true.
false.
V = "test1".
false.
false.
2 changes: 2 additions & 0 deletions tests/scryer/cli/issues/os_argv.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820
args = ["-f", "--no-add-history", "--", "test1", "--", "test2", "--"]

0 comments on commit 92b85d4

Please sign in to comment.