From 39c7e22efb9237a1e86e72973ebf0582d3d5e981 Mon Sep 17 00:00:00 2001 From: Oldes Huhuman Date: Thu, 30 Nov 2023 17:29:00 +0100 Subject: [PATCH] FEAT: allow any-string value as a `call` argument --- src/boot/natives.reb | 2 +- src/core/n-io.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/boot/natives.reb b/src/boot/natives.reb index 6714acb418..92de92c3ce 100644 --- a/src/boot/natives.reb +++ b/src/boot/natives.reb @@ -908,7 +908,7 @@ list-env: native [ call: native [ {Run another program; return immediately.} - command [string! block! file!] "An OS-local command line (quoted as necessary), a block with arguments, or an executable file" + command [any-string! block! file!] "An OS-local command line (quoted as necessary), a block with arguments, or an executable file" /wait "Wait for command to terminate before returning" /console "Runs command with I/O redirected to console" /shell "Forces command to be run from shell" diff --git a/src/core/n-io.c b/src/core/n-io.c index 1286dfddde..8d2a8bf601 100644 --- a/src/core/n-io.c +++ b/src/core/n-io.c @@ -791,7 +791,16 @@ static REBSER *Read_All_File(char *fname) if (flag_shell) flags |= FLAG_SHELL; if (flag_info) flags |= FLAG_INFO; - if (IS_STRING(arg)) { + if (IS_FILE(arg)) { + REBSER* ser = NULL; + REBSER* path = Value_To_OS_Path(arg, FALSE); + argc = 1; + ser = Make_Series(argc + 1, sizeof(REBCHR*), FALSE); + argv = (REBCHR**)SERIES_DATA(ser); + argv[0] = (REBCHR*)SERIES_DATA(path); + argv[argc] = NULL; + cmd = NULL; + } else if (ANY_STR(arg)) { REBSER * ser = NULL; cmd = Val_Str_To_OS(arg); argc = 1; @@ -810,26 +819,17 @@ static REBSER *Read_All_File(char *fname) argv = (REBCHR**)SERIES_DATA(ser); for (i = 0; i < argc; i ++) { REBVAL *param = VAL_BLK_SKIP(arg, i); - if (IS_STRING(param)) { + if (IS_FILE(param)) { + REBSER* path = Value_To_OS_Path(param, FALSE); + argv[i] = (REBCHR*)SERIES_DATA(path); + } else if (ANY_STR(param)) { argv[i] = Val_Str_To_OS(param); - } else if (IS_FILE(param)) { - REBSER *path = Value_To_OS_Path(param, FALSE); - argv[i] = (REBCHR*) SERIES_DATA(path); } else { Trap_Arg(param); } } argv[argc] = NULL; cmd = NULL; - } else if (IS_FILE(arg)) { - REBSER * ser = NULL; - REBSER *path = Value_To_OS_Path(arg, FALSE); - argc = 1; - ser = Make_Series(argc + 1, sizeof(REBCHR*), FALSE); - argv = (REBCHR**)SERIES_DATA(ser); - argv[0] = (REBCHR*) SERIES_DATA(path); - argv[argc] = NULL; - cmd = NULL; } else { Trap_Arg(arg); }