[ fix ] drop first command-line arg on node

This commit is contained in:
stefan-hoeck 2022-09-27 08:19:14 +02:00
parent f03f184af9
commit de216d3ced

View File

@ -58,15 +58,22 @@ usleep : HasIO io => (usec : Int) -> So (usec >= 0) => io ()
usleep usec = primIO (prim__usleep usec) usleep usec = primIO (prim__usleep usec)
-- Get the number of arguments -- Get the number of arguments
-- Note: node prefixes the list of command line arguments
-- with the path to the `node` executable. This is
-- inconsistent with other backends, which only list
-- the path to the running program. For reasons of
-- consistency across backends, this first argument ist
-- dropped on the node backend.
%foreign "scheme:blodwen-arg-count" %foreign "scheme:blodwen-arg-count"
supportC "idris2_getArgCount" supportC "idris2_getArgCount"
"node:lambda:() => process.argv.length" "node:lambda:() => process.argv.length - 1"
prim__getArgCount : PrimIO Int prim__getArgCount : PrimIO Int
-- Get argument number `n` -- Get argument number `n`. See also `prim__getArgCount`
-- about the special treatment of the node backend.
%foreign "scheme:blodwen-arg" %foreign "scheme:blodwen-arg"
supportC "idris2_getArg" supportC "idris2_getArg"
"node:lambda:n => process.argv[n]" "node:lambda:n => process.argv[n + 1]"
prim__getArg : Int -> PrimIO String prim__getArg : Int -> PrimIO String
||| Retrieve the arguments to the program call, if there were any. ||| Retrieve the arguments to the program call, if there were any.