1

recently came across several chained redirections to file descriptors as shown is the snippet below:

name=$(dialog --inputbox "Please enter your phone number." 10 30 3>&1 1>&2 2>&3 3>&1) || exit

... while I understand this script is

  1. Creating a new file-descriptor 3 which is is then redirecting to STDOUT,
  2. Redirecting STDOUT to STDERR
  3. STDERR to the file-descriptor 3
  4. Finally, redirecting file-descriptor 3 again to STDOUT

My question is why is this being done? It looks kind of circular to me, so it would be great if someone could explain the logic or possible purpose/use-case for wanting to chain the redirections this way.

TIA!

0 Answers0