When running IPython I can run any shell command with an exclamation mark in front it:
In [1]: !ls
file1 file2 file3 file4
In [2]: !ls file*
file1 file2 file3 file4
However, some things (in particular the use if wildcards) don't work on the Julia REPL in shell mode (after you type in the semicolon):
shell> ls file
file1 file4 file2 file3
shell> ls file*
ls: cannot access 'file*': No such file or directory
Am I missing something here? Is there a way to get wildcards to behave as they do normally in a Linux shell?
You're right, the Julia shell REPL mode is not a shell in the sense most people expect, some discussion can be found here and here. Currently, the arguments are passed as is, with no shell expansion so if the program supports a literal '*' that works fine:
shell> find -iname *
.
./file1
./file2
./file3
./file4
If it doesn't you need to figure out another way. Like calling through bash:
shell> bash -c 'ls *'
file1 file2 file3 file4
Or using Julia functions/macros:
julia> bash(str::String) = run(`bash -c $str`)
bash (generic function with 1 method)
julia> macro sh_str(str::String)
bash(str)
end
julia> sh"ls *"
file1 file2 file3 file4
Process(`bash -c 'ls *'`, ProcessExited(0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With