IO::Plumbing::Util - freebies in the bag
use IO::Plumbing::Util qw(shell_quote shell_unquote); my $bad_fn = q{pw"`sudo rm -rf *`"n3d}; print shell_quote($bad_fn); # pw\"\`\ sudo\ rm\ \-rf\ \*\`\"n3d print shell_unquote(shell_quote($bad_fn)); # identity, we hope ;)
A couple of small functions for turning command line arguments into something which you can safely paste back into the shell to run, even in the face of arbitrary weird rubbish.
Returns a string which should be safe for saving, through X buffers, and later decoding with a Bourne Shell or shell_unquote.
shell_unquote
Returns a list. Of course there are many inputs the shell would consider a special character where this module blithely lets it through.
Copyright 2007, Sam Vilain. All Rights Reserved. This program is free software; you can use it and/or modify it under the same terms as Perl itself.
To install IO::Plumbing, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Plumbing
CPAN shell
perl -MCPAN -e shell install IO::Plumbing
For more information on module installation, please visit the detailed CPAN module installation guide.