如何在不替換進程的情況下即時解密檔案?

如何在不替換進程的情況下即時解密檔案?

我需要使用以下命令動態解密該檔案來取得該檔案的來源。

. <(gpg -qd "$encrypted_filename")

sh 不支援進程替換。我無法使用 bash。請建議其他方式。

有沒有辦法在腳本中動態取得加密(GPG)檔案?

答案1

在一個第二會議:

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

在你的原來的會議:

. p
rm p

要在一個會話中完成它,並且如果您對 gpg 感到滿意Assuming "yes" on most questions,那麼:

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

帽子提示輸出評論讓我想起gpg 的--yes旗幟

答案2

INSTRUCTIONS="$(gpg -qd $encrypted_filename)"
eval $INSTRUCTIONS

相關內容