The difference between system () and shell ()

R for Windows has two functions for invoking system commands. On the one hand, you can use system () (or the newer system2 () function) to execute system commands. Alternatively, you can use shell (). In my opinion, they should both do the same. What is the difference between the two?

From reading the documentation, the shell is described as a more user-friendly shell around the system. I see that both have slightly different arguments, but I really see no reason to use a shell more user-friendly. Other than that, I see no other differences and even the execution of some basic code gives the same results (except for quotation marks).

> system('ECHO "test"') test > shell('ECHO "test"') "test" 

What will be the argument for using one and not the other?

+6
source share
1 answer

If your system commands are accepted using CMD.EXE (the default on Windows), then there is not much difference. However, if you want to use different shells, such as sh to run scripts other than CMD.exe, it can save you the prefix of each system command. It will also help in related matters, such as the need to switch all / for \ .

0
source

Source: https://habr.com/ru/post/1014322/


All Articles