Hi, on my R-3.0.2 windows (32bits) no error is thrown occurs when calling a shell command with intern=TRUE, mustWork=TRUE. Is this a intended/known behaviour?
>From the source of base::shell it is clear that mustWork is only used when intern=FALSE. This is not that clear from the help page: " Arguments mustWork a logical; if TRUE failure to run the command will give an R error, if FALSE a warning and if NA, no R message. Value If intern = TRUE, a character vector giving the output of the command, one line per character string, or an error message if the command could not be run. " Thank you. Bests, Renaud ## Example ### # no error as expected shell('notacommand') shell('notacommand', intern=TRUE) # error as expected shell('notacommand', mustWork = TRUE) # I am expecting to get an error here as well, but none is thrown shell('notacommand', intern = TRUE, mustWork = TRUE) sessionInfo() ### Output ### > # no error as expected > shell('notacommand') 'notacommand' is not recognized as an internal or external command, operable program or batch file. Warning messages: 1: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 2: In shell("notacommand") : 'notacommand' execution failed with error code 1 > shell('notacommand', intern=TRUE) [1] "'notacommand' is not recognized as an internal or external command," [2] "operable program or batch file." attr(,"status") [1] 1 Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 > # error as expected > shell('notacommand', mustWork = TRUE) 'notacommand' is not recognized as an internal or external command, operable program or batch file. Error in shell("notacommand", mustWork = TRUE) : 'notacommand' execution failed with error code 1 In addition: Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 > # I am expecting to get an error here as well, but none is thrown > shell('notacommand', intern = TRUE, mustWork = TRUE) [1] "'notacommand' is not recognized as an internal or external command," [2] "operable program or batch file." attr(,"status") [1] 1 Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 > > sessionInfo() R version 3.0.2 (2013-09-25) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel