Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Is this something you want to do in a script, not in an interactive shell? Commented Feb 28 at 7:04
  • Mostly inside scripts since redirecting output for an interactive shell is of limited use. Ideally, I would not need to restart the interpreter currently executing the script, because I'd need a way to communicate to the next iteration that the redirect is already in place and stop it from going into an endless loop. Commented Feb 28 at 7:09
  • I know that there are lots of workarounds, like defining a function with the contents of the script, and then running that function as part of a pipe -- but I'm wondering if there is a way to just change the state of the current interpreter in a standalone instruction. Commented Feb 28 at 7:11
  • You can redirect stdout with a wrapper script that you invoke instead of the original script. The wrapper script can have the #! line and a line like /path/to/original/script | gpg -aer 0x6aabe354 Commented Feb 28 at 7:11
  • I think in bash I can also use exec >(gpg -aer 0x6aabe354), but that's not portable Commented Feb 28 at 7:13