Fedora Account System
Red Hat Associate
Red Hat Customer
Description of problem: When the input separator is specified as a single tab character, the /usr/bin/column command improperly drops leading space characters when in table mode. Version-Release number of selected component (if applicable): util-linux-2.30.2-2.fc27.x86_64 How reproducible: The following bash shell code echoes a blank line, and then two lines of two columns. Each column field consists of fives spaces, then a capital letter, and then five more spaces. The columns are delimited on input by a single tab character, and are delimited on output with a single "!" character. The output is translated by converting spaces to periods for ease of viewing where the space characters should be. #################### [major@chariot ~]$ echo ; echo -en ' A \t B \n C \t D \n' | column -t -s $'\t' -o '!' | tr ' ' '.' A.....!.....B..... C.....!.....D..... #################### Since the space character is not an input delimiter in this example, the previous code should produce the following output. #################### .....A.....!.....B..... .....C.....!.....D..... #################### A single tab character is used by many system utilities as the output field delimiter. I came across this problem when using /usr/bin/comm to compare sorted files containing lines with initial spaces.
Well, this is feature for all column modes and it is there for the beginning (I see it in 10 years old code). But yes, I see the pain and maybe we can add a new command line option (e.g. --leading-space) to disable this feature. I'll add this to upstream TODO. Thanks for the idea. https://github.com/karelzak/util-linux/commit/867c15ddb8cfe77cb828da0e948b847779136e56
The original UNIX source codes for the /usr/bin/column command can be found in The Unix Tree at "http://www.tuhs.org/cgi-bin/utree.pl". Specifically the "4.3BSD Reno" (1990-06), "The Net/2 Distribution" (1991-06), and the "4.4BSD" (1993-06) have the earliest versions of /usr/bin/column. The default separator string consists of a tab followed by a space, "\t ". The default can be changed using the "-s" option from the earliest version. All the versions of /usr/bin/column have a function called maketbl() that uses the strtok() library function. The source codes for each corresponding strtok() library function are also found in The UNIX Tree. The /usr/bin/column separator string is used by the strtok() function as its delimiter string. The strtok() function will skip any leading delimiter characters in the string that it is parsing. Any character that is not in the delimiter string is not a delimiter character and is treated like any other character. A new command-line option (e.g. --leading-space) should not be needed to match the original intended operation of the /usr/bin/column command. If a separator string is supplied with the "-s" option, then any characters that are not in that string do not need special treatment. See the following links. http://www.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Reno/src/usr.bin/column/column.c http://www.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Reno/src/lib/libc/string/strtok.c http://www.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/usr.bin/column/column.c http://www.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/lib/libc/string/strtok.c http://www.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/src/usr.bin/column/column.c http://www.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/src/lib/libc/string/strtok.c
I read the code again (util-linux version is based on the original BSD code) and you're right. The change (bug) has been introduced in the recent version. The command line option is unnecessary. The bug is fixed in upstream tree, I'll backport it to f27. Thanks!
Fixed version: echo ; echo -en ' A \t B \n C \t D \n' | ./column -t -s $'\t' -o '!' | tr ' ' '.' .....A.....!.....B..... .....C.....!.....D.....
util-linux-2.30.2-3.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-3563dbdf5e
util-linux-2.32-2.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-318a38494a
util-linux-2.32-2.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-318a38494a
util-linux-2.30.2-3.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-3563dbdf5e
util-linux-2.30.2-3.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.
util-linux-2.32-2.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.