Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Nothing up my sleeve...
- unset ANSWER
- # dupe stdout (fd 1) to a new fd, which we call TERM_OUT (redirection)
- # change the shell's idea of what stdout is to be TERM_OUT (exec)
- exec {TERM_OUT}>&1
- # set-up a command substitution
- # the command is a subshell expression, with redirection applied
- # the redirection dupes stdout again, calling the new fd $OOB here
- # the subshell itself invokves dialog(1)
- # we apply redirection to this to put dialog's output back on the terminal
- # and we tell dialog to send its results to the $OOB fd we opened earlier
- # OOB = out-of-band
- ANSWER=$( ( dialog --output-fd $OOB --inputbox 'Speak Friend and enter' 0 0 > /dev/fd/$TERM_OUT ) {OOB}>&1 )
- # Ta-da!
- echo ANSWER=\<$ANSWER\>
Advertisement
Add Comment
Please, Sign In to add comment