I'm using the linux "dialog" utility to create a simple UI. However, there is a text in infobox and I want to insert tab characters in order to properly align the text.

But it seems, that dialog does not accept tab character. Also, the --tab-correct option did not help. If I write \t, it apperas at \t in the infobox.

dialog --title "Hello" --tab-correct --infobox "tab \t test" 20 100

If I insert a tab in the command string:

dialog --title "Hello" --tab-correct --infobox "tab         test" 20 100

it appears as a single space.

Is there a way to insert tab in the infobox text?


You should use the --no-collapse option, instead of --tab-correct, and insert literal tabs in your string, for example with

"star "$'\t'" end" 

or using Ctrl-v and pressing the Tab key.

  • Thank you very much! This --no-collapse option solved the problem :) – Nuclear Apr 4 '12 at 14:20

Well, I don't know dialog, but sometimes in Linux when \t doesn't interpreted as Tab, try

"`echo -e "\t"`"

Try this:

declare -r TAB="`echo -e "\t"`"
echo -e "A${TAB}B"

The command string you say that appears as a single space is appearing as 8 spaces here, not a tab (but maybe that's StackExchange).

Debugging this may be a bit tricky. There are several things that may or may not "cook" tabs: the terminal, when inserting the character; the shell, when processing the input; the underlying terminal mode (cooked mode vs. raw mode), and, in the end, dialog itself.

To make things even more confusing, if you use echo to generate a tab, or if you somehow else generate a tab, there's still a chance the terminal emulator decides to wash that off.

A commonly seen keystroke to escape this kind of control characters is C-v (that is, Control+V, CTRL+V). If you hit that, then tab, you may get a real tab inserted. Here with the GNU bash and urxvt, it works.

Properly debugging this requires knowing exactly what's the issue (that is, what's eating the tab). Simply putting \t there won't work unless either dialog or your shell have the feature to translate these escaped sequences. If you want those, then follow @Eran Ben-Natan's advice and use GNU echo's enhanced mode (other implementations may/will differ — there's no specific behavior specified in POSIX (IEEE 1003.1 2008, page 2615, line 84306)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.