Date: Thu, 14 Nov 2024 00:30:32 +0100
From: "#!microsuxx" <[email protected]>
Message-ID:
<caalkereref+_zgit6+n7hbgnrai0q-xto2f5rfnttuq6cj9...@mail.gmail.com>
| i just dunno the exec cmd to bring back the fd 1 and 2 after usage back to
| tty , or restore from saved
Assuming that this is even slightly relevant to the question here (whether
any of this is really necessary), that you accomplish by a sequence like:
exec 7<&0 8>&1 9>&2
exec 0<... 1>... 2>... # (whatever needs to be done)
# commands to use the modified
# stdin, stdout, stderr, (or some subset)
# go here
exec <&7 >&8 2>&9 7<&- 8>&- 9>&- # to restore things to as they
were.
You can use anything you like instead of 7, 8 & 9, they just need to be
unused file descriptors that the shell you're using will allow you to
access - all shells allow fd's 0..9 to be used by scripts (but 0, 1 & 2 are
already in use), some allow lots more than that. You don't need to save
or restore anything you don't need to modify, obviously (ie: don't bother
saving stdin and then not assigning it elsewhere, and if you don't save
it don't attempt to restore it later).
kre