A small package to run string as shell command

Note that doing this sort of thing has all of the problems that @StefanKarpinski described in his Shelling Out Sucks blog post. It will have unexpected results if basename(r) contains spaces, for example. (Maybe this is what @yuyichao was referring to with “buggy code”.) That’s why it would be better to learn to use Cmd objects.

The main thing that can’t be done directly with Cmd objects in this example is the *.png globbing (implement more special shell-like functionality in backticks · Issue #20401 · JuliaLang/julia · GitHub). However, you can use the Glob.jl package for that:

using Glob
run(`convert $(glob("*.png", r)) $(basename(r)).mp4`)
6 Likes