Skip to content

Commit

Permalink
FEAT: allow any-string value as a call argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Nov 30, 2023
1 parent a730144 commit 39c7e22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/boot/natives.reb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 14 additions & 14 deletions src/core/n-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 39c7e22

Please sign in to comment.