Skip to main content
deleted 309 characters in body
Source Link
yaegashi
  • 12.6k
  • 2
  • 39
  • 42

You can use the following redirections:

3>&1 text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >&3>/dev/tty) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac 

Here's what's going on:

  1. Dup fd 1 to fd 3 to preserve the original stdout (/dev/tty)
  2. fd 1 gets connected to a pipe by the command substitution construct
  3. Dup fd 1 to fd 2 (dialog's stderr is connected to the pipe)
  4. Dup fd 3 to fd 1 (dialog's stdout is connected to the original stdout)

You can use the following redirections:

3>&1 text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >&3) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac 

Here's what's going on:

  1. Dup fd 1 to fd 3 to preserve the original stdout (/dev/tty)
  2. fd 1 gets connected to a pipe by the command substitution construct
  3. Dup fd 1 to fd 2 (dialog's stderr is connected to the pipe)
  4. Dup fd 3 to fd 1 (dialog's stdout is connected to the original stdout)

You can use the following redirections:

text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >/dev/tty) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac 
added 310 characters in body
Source Link
yaegashi
  • 12.6k
  • 2
  • 39
  • 42

You can use the following redirections:

3>&1 text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >&3) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac 

Here's what's going on:

  1. Dup fd 1 to fd 3 to preserve the original stdout (/dev/tty)
  2. fd 1 gets connected to a pipe by the command substitution construct
  3. Dup fd 1 to fd 2 (dialog's stderr is connected to the pipe)
  4. Dup fd 3 to fd 1 (dialog's stdout is connected to the original stdout)

You can use the following redirections:

3>&1 text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >&3) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac 

You can use the following redirections:

3>&1 text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >&3) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac 

Here's what's going on:

  1. Dup fd 1 to fd 3 to preserve the original stdout (/dev/tty)
  2. fd 1 gets connected to a pipe by the command substitution construct
  3. Dup fd 1 to fd 2 (dialog's stderr is connected to the pipe)
  4. Dup fd 3 to fd 1 (dialog's stdout is connected to the original stdout)
Source Link
yaegashi
  • 12.6k
  • 2
  • 39
  • 42

You can use the following redirections:

3>&1 text=$(dialog --backtitle 'foo' --title 'bar' --clear --inputbox 'baz' 0 0 2>&1 >&3) case $? in 0) echo "Approved with: $text" ;; 1) echo "Canceled by the cancel button" ;; 255|*) echo "Canceled by the escape key" ;; esac