Here's a [link](http://stackoverflow.com/a/40435998/2632107) to a *stackoverflow* answer that maybe of further assistance; I have a project that does bulk decryption/encryption, and due to *GnuPG* being very strict about passphrases, learned the hard way that `--passphrase` only works on rare occasions. Instead consider the `--passphrase-fd` option to be more reliable.

This [script](https://github.com/S0AndS0/Perinoid_Pipes/blob/master/Script_Helpers/Paranoid_Pipes_Scenario_One.sh) makes *proper* use of the `--passphrase -fd` option, and has been tested publicly via *Travis-CI* where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with:

 #!/usr/bin/env bash
 # Set some variables for easy modding
 Var_fd='9'
 Var_pass="/path/to/passphrase.file"
 Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt"
 Var_output_location="out.txt"
 Arr_string=( "$@" )
 # Open file descriptor and shove the passphrase file into it
 if [ -f "${Var_pass}" ]; then
 exec ${Var_fd}<"${Var_pass}"
 else
 exec ${Var_fd}<(echo "${Var_pass}")
 fi
 # Pipe input array though gpg and append to output file
 cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location}
 # Do not forget to close the file descriptor
 exec ${Var_fd}>&-

While the above isn't as fancy as the linked protect at GitHub it *should* be even more functional than the answer linked at the beginning of this post.

Happy hacking.