@@ -141,6 +141,25 @@ parsing the file once it reaches to the `exec` statement.
141
141
```
142
142
instead. Note that with this strategy [`PROGRAM_FILE`](@ref) will not be set.
143
143
144
+ ### Why doesn't ` run ` support ` * ` or pipes for scripting external programs?
145
+
146
+ Julia's [ ` run ` ] ( @ref ) function launches external programs * directly* , without
147
+ invoking an [ operating-system shell] ( https://en.wikipedia.org/wiki/Shell_(computing) )
148
+ (unlike the ` system("...") ` function in other languages like Python, R, or C).
149
+ That means that ` run ` does not perform wildcard expansion of ` * ` ([ "globbing"] ( https://en.wikipedia.org/wiki/Glob_(programming) ) ),
150
+ nor does it interpret [ shell pipelines] ( https://en.wikipedia.org/wiki/Pipeline_(Unix) ) like ` | ` or ` > ` .
151
+
152
+ You can still do globbing and pipelines using Julia features, however. For example, the built-in
153
+ [ ` pipeline ` ] ( @ref ) function allows you to chain external programs and files, similar to shell pipes, and
154
+ the [ Glob.jl package] ( https://github.com/vtjnash/Glob.jl ) implements POSIX-compatible globbing.
155
+
156
+ You can, of course, run programs through the shell by explicitly passing a shell and a command string to ` run ` ,
157
+ e.g. ``` run(`sh -c "ls > files.txt"`) ``` to use the Unix [ Bourne shell] ( https://en.wikipedia.org/wiki/Bourne_shell ) ,
158
+ but you should generally prefer pure-Julia scripting like ``` run(pipeline(`ls`, "files.txt")) ``` .
159
+ The reason why we avoid the shell by default is that [ shelling out sucks] ( https://julialang.org/blog/2012/03/shelling-out-sucks/ ) :
160
+ launching processes via the shell is slow, fragile to quoting of special characters, has poor error handling, and is
161
+ problematic for portability. (The Python developers came to a [ similar conclusion] ( https://www.python.org/dev/peps/pep-0324/#motivation ) .)
162
+
144
163
## Functions
145
164
146
165
### I passed an argument ` x ` to a function, modified it inside that function, but on the outside, the variable ` x ` is still unchanged. Why?
0 commit comments