SUMMARY The command line arguments set via `Rf_initialize_R` and `R_set_command_line_arguments` are incorrect. The first argument must be the name of the program by which R was invoked. R assumes that the previous is true, and so it skips the first command line argument. for Unix, in `Rf_initialize_R`: https://github.com/wch/r-source/blob/f4de6dfdeb1d8b100d6a70c259c80a20508a4309/src/unix/system.c#L407 for Windows, in `cmdlineoptions`: https://github.com/wch/r-source/blob/589b76ba28bb97e9d628f6e4ae1735c4e2660b3f/src/gnuwin32/system.c#L1180 for all, in `R_common_command_line`: https://github.com/wch/r-source/blob/f4de6dfdeb1d8b100d6a70c259c80a20508a4309/src/main/CommandLineArgs.c#L103 I would suggest something more like: ``` int argc = 4; char* argv[4] = { qstrdup ("rkward"), qstrdup ("--slave"), qstrdup ("--no-save"), qstrdup ("--no-restore") }; ``` But I have one more suggestion. I think you should not be using option `--slave`. In interactive use, this turns off printing the prompt when waiting for input and turns off printing a continuation prompt for code that spans multiple lines. That doesn't seem like what you want. Instead, you should replace it with `--quiet` (or `--silent` or `-q`, but I prefer `--quiet`). When combined with `--no-save`, you end up with the same R settings except `R_NoEcho` is `FALSE`, as it should be: ``` int argc = 4; char* argv[4] = { qstrdup ("rkward"), qstrdup ("--quiet"), qstrdup ("--no-save"), qstrdup ("--no-restore") }; ``` OBSERVED RESULT ```R > commandArgs() [1] "--slave" [2] "--no-save" [3] "--no-restore" ``` EXPECTED RESULT ```R > commandArgs() [1] "rkward" [2] "--quiet" [3] "--no-save" [4] "--no-restore" ```
Thanks for the detailed report! This appears to date back all the way to version 0.2.0 in 2004. There probably never was a good reason for the inclusion of --slave, anyway, so I will just remove this, without replacement. It may be worth pointing out, however, that the input and continuation prompts are not actually considered, and options(prompt="something> ") continues to be ignored inside the RKWard R Console window. (Supporting custom prompts would currently break the syntax highlighting, there).
Git commit 083220da6af7240cd99d195a3cb7bdcdbf188fda by Thomas Friedrichsmeier. Committed on 29/07/2024 at 11:56. Pushed by tfry into branch 'master'. Fix setting R commandline options M +1 -0 ChangeLog M +1 -1 rkward/rbackend/rkrbackend.cpp https://invent.kde.org/education/rkward/-/commit/083220da6af7240cd99d195a3cb7bdcdbf188fda
Okay, awesome, thank you so much for solving this so quickly!