Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: Having to manually escape quote character in args to "system"?

by vr (Curate)
on Sep 20, 2017 at 11:53 UTC ( [id://1199727]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    >perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say f
    +or @ARGV', 1, shell_quote(qq(\x5c\x5c \x5c)), 2"
    1
    \\\ \
    2
    
  2. or download this
    perl -E "system $^X, '-E', 'say for @ARGV', qq(\x22abc\x22 d e)"
    perl -E "system $^X, '-E', 'say for @ARGV', qq(a\x5c\x5c\x5cb d\x22e f
    +\x22g h)"
    perl -E "system $^X, '-E', 'say for @ARGV', qq(a\x5c\x5c\x5c\x22b c d)
    +"
    perl -E "system $^X, '-E', 'say for @ARGV', qq(a\x5c\x5c\x5c\x5c\x22b 
    +c\x22 d e)"
    
  3. or download this
            $arg =~ s/(\\(?!.*\\)|\\(?=\\)|")/\\$1/g;
    
  4. or download this
            $arg =~ s/\\(?=\\*(?:"|$))/\\\\/g;
            $arg =~ s/"/\\"/g;
    
  5. or download this
    perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say fo
    +r @ARGV', map {shell_quote $_} qw(abc d e)"
    perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say fo
    +r @ARGV', map {shell_quote $_} qq(a\x5c\x5c\x5cb), 'de fg', 'h'"
    perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say fo
    +r @ARGV', map {shell_quote $_} qq(a\x5c\x22b), 'c', 'd'"
    perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say fo
    +r @ARGV', map {shell_quote $_} qq(a\x5c\x5cb c), 'd', 'e'"
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1199727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found