whiptail: How to redirect output to environment variable?

前端 未结 2 438
春和景丽
春和景丽 2020-12-05 20:45

I\'m trying to use whiptail as it\'s a lightweight alternative to dialog and seems to be installed by default in most systems (i.e., people don\'t have to go around and inst

相关标签:
2条回答
  • 2020-12-05 20:48

    It appears that whiptail(1) writes its control output to the termininal based on the setting of the TERM environment variable. Conseqently, you can't use the standard output stream of whiptail(1) to set a variable. Also, whiptail(1) writes the user-input of the input box to the standard error stream so, again, you can't use its standard output stream to set a variable.

    0 讨论(0)
  • 2020-12-05 21:10

    This is probably because whiptail uses stdin and stdout to print the input box, so you cannot redirect stderr directly to stdout, but you need to swap them, e.g:

    foobar=$(whiptail --inputbox "Enter some text" 10 30 3>&1 1>&2 2>&3)
    
    0 讨论(0)
提交回复
热议问题