Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

column -ts '<TAB>' misaligns tab delimited files #575

Closed
unode opened this issue Feb 12, 2018 · 1 comment
Closed

column -ts '<TAB>' misaligns tab delimited files #575

unode opened this issue Feb 12, 2018 · 1 comment

Comments

@unode
Copy link

unode commented Feb 12, 2018

 column -ts '<TAB>' <(echo "<TAB>col1<TAB>col2\nrow<TAB>1<TAB>2")

where <TAB> is a literal TAB character introduced with Ctrl+v Tab, produces:

col1  col2
row   1     2

instead of the correct:

     col1  col2
row  1     2

which is produced if instead of a <TAB> a , is used:

 column -ts ',' <(echo ",col1,col2\nrow,1,2")
     col1  col2
row  1     2

The cause seems to be that the <TAB> character is considered 'whitespace' and is stripped from the beginning of the line, causing the alignment shift.

karelzak added a commit that referenced this issue Feb 12, 2018
Non-space separator:

	$ echo -e ",col1,col2\nrow,1,2" | column -t -s ","  --table-columns A,B,C
	A    B     C
	     col1  col2
	row  1     2

Space-char (\t) separator:

	$ echo -e "\tcol1\tcol2\nrow\t1\t2" | column -t -s "$(echo -e '\t')"  --table-columns A,B,C
	A     B     C
	col1  col2
	row   1     2

Fixed version:

	$ echo -e "\tcol1\tcol2\nrow\t1\t2" | column -t -s "$(echo -e '\t')"  --table-columns A,B,C
	A    B     C
	     col1  col2
	row  1     2

Addresses: #575
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
Copy link
Collaborator

Yes, column(1) ignores space chars at the begin of the input line. Fixed. Let's hope it does not introduce any regression.

echo -e "\tcol1\tcol2\nrow\t1\t2" | ./column -t -s "$(echo -e '\t')"  --table-columns A,B,C
A    B     C
     col1  col2
row  1     2

karelzak added a commit that referenced this issue Mar 27, 2018
The bug has been introduced during column(1) rewrite. The function
read_input() need to skip leading space only temporary to detect empty
lines, but the rest of the code has to use the original buffer (line).
I've tried to fix one of the symptoms by 5c7b67f
(alter), but this solution is unnecessary and too complex.

Changes:

* don't ignore leading space
* remove unnecessary stuff introduced by 5c7b67f
* fix regression test with incorrect separator

Addresses: #575
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1560283
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Mar 27, 2018
The bug has been introduced during column(1) rewrite. The function
read_input() need to skip leading space only temporary to detect empty
lines, but the rest of the code has to use the original buffer (line).

Addresses: #575
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1560283
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Jul 12, 2018
The bug has been introduced during column(1) rewrite. The function
read_input() need to skip leading space only temporary to detect empty
lines, but the rest of the code has to use the original buffer (line).
I've tried to fix one of the symptoms by 5c7b67f
(alter), but this solution is unnecessary and too complex.

Changes:

* don't ignore leading space
* remove unnecessary stuff introduced by 5c7b67f
* fix regression test with incorrect separator

Addresses: #575
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1560283
Signed-off-by: Karel Zak <kzak@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants