When I run the following command in Terminal.app:
echo -e "a\tb\tc\td\te\tf\tg\tyo"
I should get the following output (using a 40-column window so that lines don't wrap here, and replacing tabs with spaces so that the correct amount of space is shown here):
a b c d e f g yo
But instead, I get this output:
a b c d e y o
As you can see, the
g are missing.
After trying various strings, I think the problem is that a tab at the end of a line does not advance the output to the next line, but instead leaves the output cursor one character before the line end. For example (still assuming a 40-column terminal), 4 tabs puts the cursor at position 32 of line 1. Another tab should put the cursor at position 0 of line 2, but instead the cursor is at position 39 of line 1, leaving room for one more character to be printed—and even at that point, the cursor is not advanced to the next line, so another tab will put us back to position 39. Hence, an unlimited number of (single-character + tab) strings will be silently ignored.
I've experimented with a variety of:
- shells (including
- terminal widths (including 40 columns, 80, and many others)
- terminal types (including
- terminal character encodings (including
- terminal settings (including
Escape non-ASCII input)
Also, a friend ran similar commands on a Linux system with a different terminal, and did not encounter the same bug.
Anybody know how to fix this? I'd be much obliged, as this bug is making it might tricky to debug some home-made shell scripts running on tab-separated files.