diff --git a/src/lib/os.pl b/src/lib/os.pl index 10eb00408..aa955e9b8 100644 --- a/src/lib/os.pl +++ b/src/lib/os.pl @@ -138,7 +138,8 @@ argv(Argv) :- can_be(list, Argv), '$argv'(Argv0), - ( append(_, ["--"|Argv], Argv0) -> - true - ; Argv = [] + ( append(_, ["--"|Argv1], Argv0) -> + Argv = Argv1 + ; + Argv = [] ). diff --git a/tests/scryer/cli/issues/os_argv-no-final--.stderr b/tests/scryer/cli/issues/os_argv-no-final--.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/tests/scryer/cli/issues/os_argv-no-final--.stdin b/tests/scryer/cli/issues/os_argv-no-final--.stdin new file mode 100644 index 000000000..59ba556c8 --- /dev/null +++ b/tests/scryer/cli/issues/os_argv-no-final--.stdin @@ -0,0 +1,6 @@ +os:argv(V). +os:argv(["test1"|_]). +os:argv(["--"|_]). +os:argv([V, "--"|_]). +os:argv(["test2"|_]). +os:argv([]). diff --git a/tests/scryer/cli/issues/os_argv-no-final--.stdout b/tests/scryer/cli/issues/os_argv-no-final--.stdout new file mode 100644 index 000000000..9558ca7f4 --- /dev/null +++ b/tests/scryer/cli/issues/os_argv-no-final--.stdout @@ -0,0 +1,6 @@ + V = ["test1","--","test2"]. + true. + false. + V = "test1". + false. + false. diff --git a/tests/scryer/cli/issues/os_argv-no-final--.toml b/tests/scryer/cli/issues/os_argv-no-final--.toml new file mode 100644 index 000000000..831d0fddd --- /dev/null +++ b/tests/scryer/cli/issues/os_argv-no-final--.toml @@ -0,0 +1,2 @@ +# https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820 +args = ["-f", "--no-add-history", "--", "test1", "--", "test2"] diff --git a/tests/scryer/cli/issues/os_argv.stderr b/tests/scryer/cli/issues/os_argv.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/tests/scryer/cli/issues/os_argv.stdin b/tests/scryer/cli/issues/os_argv.stdin new file mode 100644 index 000000000..59ba556c8 --- /dev/null +++ b/tests/scryer/cli/issues/os_argv.stdin @@ -0,0 +1,6 @@ +os:argv(V). +os:argv(["test1"|_]). +os:argv(["--"|_]). +os:argv([V, "--"|_]). +os:argv(["test2"|_]). +os:argv([]). diff --git a/tests/scryer/cli/issues/os_argv.stdout b/tests/scryer/cli/issues/os_argv.stdout new file mode 100644 index 000000000..2916310ce --- /dev/null +++ b/tests/scryer/cli/issues/os_argv.stdout @@ -0,0 +1,6 @@ + V = ["test1","--","test2","--"]. + true. + false. + V = "test1". + false. + false. diff --git a/tests/scryer/cli/issues/os_argv.toml b/tests/scryer/cli/issues/os_argv.toml new file mode 100644 index 000000000..62b83a7ae --- /dev/null +++ b/tests/scryer/cli/issues/os_argv.toml @@ -0,0 +1,2 @@ +# https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820 +args = ["-f", "--no-add-history", "--", "test1", "--", "test2", "--"]