@@ -699,7 +699,8 @@ synconcealed({lnum}, {col}) List info about concealing
699699synstack({lnum} , {col} ) List stack of syntax IDs at {lnum} and
700700 {col}
701701system({expr} [, {input} ]) String output of shell command/filter {expr}
702- systemlist({expr} [, {input} ]) List output of shell command/filter {expr}
702+ systemlist({expr} [, {input} ])
703+ List output of shell command/filter {expr}
703704tabpagebuflist([{arg} ]) List list of buffer numbers in tab page
704705tabpagenr([{arg} ]) Number number of current or last tab page
705706tabpagewinnr({tabarg} [, {arg} ])
@@ -11694,6 +11695,30 @@ system({expr} [, {input}]) *system()* *E677*
1169411695 Get the output of the shell command {expr} as a | String | . See
1169511696 | systemlist() | to get the output as a | List | .
1169611697
11698+ {expr} can be a | String | or a | List | .
11699+ When {expr} is a | String | , the command is executed through the
11700+ shell (see below for how the command is constructed).
11701+
11702+ *E1575*
11703+ When {expr} is a | List | , the first item is the executable and
11704+ the remaining items are passed as arguments directly. The
11705+ command is executed without using a shell, similar to
11706+ | job_start() | . Since no shell is involved, shell features
11707+ such as redirection, piping, globbing, environment variable
11708+ expansion and backtick expansion will not work. Characters
11709+ like ">" are passed as literal arguments to the command, not
11710+ interpreted as redirection. Use this form when arguments may
11711+ contain special characters that should not be interpreted by
11712+ the shell. Example: >
11713+ :let out = system(['grep', '-r', 'pattern', '.'])
11714+ < With the String form ">" would be shell redirection, but
11715+ with a List it is passed as a literal argument: >
11716+ :let out = system(['echo', 'hello', '>', 'world'])
11717+ < This outputs "hello > world", not redirect to a file.
11718+
11719+ To use the shell explicitly with a List: >
11720+ :let out = system(['/bin/sh', '-c', 'echo $HOME'])
11721+ <
1169711722 When {input} is given and is a | String | this string is written
1169811723 to a file and passed as stdin to the command. The string is
1169911724 written as-is, you need to take care of using the correct line
@@ -11719,11 +11744,11 @@ system({expr} [, {input}]) *system()* *E677*
1171911744 being echoed on the screen. >
1172011745 :silent let f = system('ls *.vim')
1172111746<
11722- Note: Use | shellescape() | or | ::S | with | expand() | or
11723- | fnamemodify() | to escape special characters in a command
11724- argument. Newlines in {expr} may cause the command to fail.
11725- The characters in 'shellquote' and 'shellxquote' may also
11726- cause trouble.
11747+ Note: When {expr} is a String, use | shellescape() | or | ::S |
11748+ with | expand() | or | fnamemodify() | to escape special
11749+ characters in a command argument. Newlines in {expr} may
11750+ cause the command to fail. The characters in 'shellquote'
11751+ and 'shellxquote' may also cause trouble.
1172711752 This is not to be used for interactive commands.
1172811753
1172911754 The result is a String. Example: >
@@ -11736,7 +11761,8 @@ system({expr} [, {input}]) *system()* *E677*
1173611761 To avoid the string being truncated at a NUL, all NUL
1173711762 characters are replaced with SOH (0x01).
1173811763
11739- The command executed is constructed using several options:
11764+ When {expr} is a String, the command executed is constructed
11765+ using several options:
1174011766 'shell' 'shellcmdflag' 'shellxquote' {expr} 'shellredir' {tmp} 'shellxquote'
1174111767 ({tmp} is an automatically generated file name).
1174211768 For Unix, braces are put around {expr} to allow for
@@ -11763,6 +11789,9 @@ system({expr} [, {input}]) *system()* *E677*
1176311789systemlist({expr} [, {input} ]) *systemlist()*
1176411790 Same as | system() | , but returns a | List | with lines (parts of
1176511791 output separated by NL) with NULs transformed into NLs.
11792+ Like | system() | , {expr} can be a | String | (executed through
11793+ the shell) or a | List | (executed directly without a shell).
11794+ See | system() | for details.
1176611795 Output is the same as | readfile() | will output with {binary}
1176711796 argument set to "b", except that there is no extra empty item
1176811797 when the result ends in a NL.
0 commit comments