1

I need to source the file by decrypting it on the fly using the below command.

. <(gpg -qd "$encrypted_filename")

sh is not supporting process substitution. I can't use bash. Please suggest some other way.

Is there a way to source an encrypted (GPG) file on-the-fly in a script?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250

2 Answers2

1

In a second session:

mkfifo p &&
gpg -d -o p "$encrypted_filename"
# File `p' exists. Overwrite? (y/N) y

In your original session:

. p
rm p

To accomplish it in one session, and if you're comfortable with gpg Assuming "yes" on most questions, then:

mkfifo p &&
gpg --yes -d -o p file.gpg & 
. p &&
rm p

Hat tip to Outurnate's comment reminding me of gpg's --yes flag.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
0
INSTRUCTIONS="$(gpg -qd $encrypted_filename)"
eval $INSTRUCTIONS
towo
  • 101
  • 3