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 fd 4 (using redirection)
- # change the shell's idea of what stdout is to be fd 4 (exec)
- exec 4>&1
- # set-up a command substitution
- # the command is a subshell expression, with redirection applied
- # the redirection dupes stdout again, on to fd 3
- # 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 fd 3 we opened earlier
- ANSWER=$( ( dialog --output-fd 3 --inputbox 'Speak Friend and enter' 0 0 > /dev/fd/4 ) 3>&1 )
- # Ta-da!
- echo ANSWER=\<$ANSWER\>
Advertisement
Add Comment
Please, Sign In to add comment