Another approach is to have powerful enough language that allows you to guard against the shell injection. I wrote a syntax form allowing to do this:
(sh "cat " file " >" output)
With file being bound to "foo'bar" and output to "x", it is automatically translated into
cat 'foo'\''bar' >'x'
This gives you the flexibility to use shell (sometimes it just is the most concise way) while being safe against injection.
I believe for example in rust you should be able to do the same.