Escaping parentheses when sending GPG passphrase to a Perl script Escaping parentheses when sending GPG passphrase to a Perl script shell shell

Escaping parentheses when sending GPG passphrase to a Perl script


The \Q and \E escape sequences are used to escape all "special" characters between them.

`gpg --passphrase \Q$gpgpp\E --batch -o $gpgofile -d $file`;

This should be done any time you have a variable that may contain characters which need to be escaped.

http://perldoc.perl.org/functions/quotemeta.html


Enclose the variables in quotes:

gpg --passphrase "$gpgpp" --batch -o "$gpgofile" -d "$file"

Otherwise, the shell will try to interpret contents of the variables as expressions.