Day 22: Safer system() alternative (Sys::Run::Safer)
About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.
Sys::Run::Safer is an attempt to create a safer API for running programs.
As we might already know, Perl's system() may or may not call a shell depending on a number of things. If we want to avoid a shell, doing system @ary or even system $cmd, @args is not enough as Perl might still invoke shell if @ary is only 1-element long or when @args is empty. I realized and got reminded of this myself only recently, it was a long time ago since I read the documentation for system() and I've been system @ary all these years thinking it was enough. You actually need to do this ugly thing to make sure you avoid a shell: system { $ary[0] } @ary which I'm pretty sure a lot of people don't remember or bother to use. Thus, it's an API mistake.
