Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

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.

share|improve this answer
    
Thank you very much! This --no-collapse option solved the problem :) –  Nuclear Apr 4 '12 at 14:20
add comment

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)).

share|improve this answer
add comment

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"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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