@@ -1040,25 +1040,6 @@ defmodule System do
1040
1040
> such as `.exe`, and double check the program is indeed not a batch
1041
1041
> file or `.com` application.
1042
1042
1043
- ## Examples
1044
-
1045
- iex> System.cmd("echo", ["hello"])
1046
- {"hello\n", 0}
1047
-
1048
- iex> System.cmd("echo", ["hello"], env: [{"MIX_ENV", "test"}])
1049
- {"hello\n", 0}
1050
-
1051
- If you want to stream the output to Standard IO as it arrives:
1052
-
1053
- iex> System.cmd("echo", ["hello"], into: IO.stream())
1054
- hello
1055
- {%IO.Stream{}, 0}
1056
-
1057
- If you want to read lines:
1058
-
1059
- iex> System.cmd("echo", ["hello\nworld"], into: [], lines: 1024)
1060
- {["hello", "world"], 0}
1061
-
1062
1043
## Options
1063
1044
1064
1045
* `:into` - injects the result into the given collectable, defaults to `""`
@@ -1122,6 +1103,26 @@ defmodule System do
1122
1103
1123
1104
If you desire to execute a trusted command inside a shell, with pipes,
1124
1105
redirecting and so on, please check `shell/2`.
1106
+
1107
+ ## Examples
1108
+
1109
+ iex> System.cmd("echo", ["hello"])
1110
+ {"hello\n", 0}
1111
+
1112
+ iex> System.cmd("echo", ["hello"], env: [{"MIX_ENV", "test"}])
1113
+ {"hello\n", 0}
1114
+
1115
+ If you want to stream the output to Standard IO as it arrives:
1116
+
1117
+ iex> System.cmd("echo", ["hello"], into: IO.stream())
1118
+ hello
1119
+ {%IO.Stream{}, 0}
1120
+
1121
+ If you want to read lines:
1122
+
1123
+ iex> System.cmd("echo", ["hello\nworld"], into: [], lines: 1024)
1124
+ {["hello", "world"], 0}
1125
+
1125
1126
"""
1126
1127
@ spec cmd ( binary , [ binary ] , cmd_opts ) :: { Collectable . t ( ) , exit_status :: non_neg_integer }
1127
1128
def cmd ( command , args , opts \\ [ ] ) when is_binary ( command ) and is_list ( args ) do
0 commit comments