Nevermind I misread your question as already having the path. Sorry.
The latter is explicitly talking about avoiding the shell and both offer passing arguments explicitly.
I'm not aware of safe placeholder invocations, and the variety of possible CLI arguments is huge.
But you could consider to examine and untaint your file argument.
-e $file should tell you if it exists (hence not work with evil injections) and examining the path should tell you if it's inside an allowed location.
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|Replies are listed 'Best First'.|
Re^2: Safely capturing the output of an external program
by AppleFritter (Vicar) on Mar 09, 2020 at 07:58 UTC
by LanX (Saint) on Mar 09, 2020 at 10:51 UTC