Should I escape shell arguments in Perl?

后端 未结 5 1184
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 08:00

When using system() calls in Perl, do you have to escape the shell args, or is that done automatically?

The arguments will be user input, so I want to make sure this

5条回答
  •  长发绾君心
    2020-12-31 08:41

    If you use system "$cmd @args" (a string), then you have to escape the arguments because a shell is invoked.

    Fortunately, for double quoted strings, only four characters need escaping:

    "    - double quote
    $    - dollar
    @    - at symbol
    \    - backslash
    

提交回复
热议问题