summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2010-02-01 15:19:08 +0000
committerPádraig Brady <P@draigBrady.com>2010-02-01 15:36:56 +0000
commitf86bb6967dba1e2b6026997963a90e00cd641490 (patch)
tree0b4451e967924bfba4c42f9c819c0e33b1b53c95 /src
parent819aa9eba741c36bb522cbc2c7f10e24d190f945 (diff)
downloadcoreutils-f86bb6967dba1e2b6026997963a90e00cd641490.tar.xz
join: make -t '' operate on the whole line
Previously passing an empty parameter to -t would raise an error, but now it means to treat each line as a single field for matching. This matches the default operation of `sort` which is usually used in conjunction with join. * src/join.c (main): Set the field delimiter to '\n' if an empty parameter is passed to -t. (usage): Mention the operation of -t ''. * tests/misc/join: Add 2 new tests, for the existing -t '\0' and the new -t '' functionality. * doc/coreutils.texi (join invocation): Mention that join -t '' always operates on the whole line, while join -t '\0' usually does. * NEWS: Mention the change in behavior.
Diffstat (limited to 'src')
-rw-r--r--src/join.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/join.c b/src/join.c
index 6030a01b3..b1f3310ec 100644
--- a/src/join.c
+++ b/src/join.c
@@ -212,7 +212,8 @@ the remaining fields from FILE1, the remaining fields from FILE2, all\n\
separated by CHAR.\n\
\n\
Important: FILE1 and FILE2 must be sorted on the join fields.\n\
-E.g., use `sort -k 1b,1' if `join' has no options.\n\
+E.g., use ` sort -k 1b,1 ' if `join' has no options,\n\
+or use ` join -t '' ' if `sort' has no options.\n\
Note, comparisons honor the rules specified by `LC_COLLATE'.\n\
If the input is not sorted and some lines cannot be joined, a\n\
warning message will be given.\n\
@@ -1040,8 +1041,8 @@ main (int argc, char **argv)
{
unsigned char newtab = optarg[0];
if (! newtab)
- error (EXIT_FAILURE, 0, _("empty tab"));
- if (optarg[1])
+ newtab = '\n'; /* '' => process the whole line. */
+ else if (optarg[1])
{
if (STREQ (optarg, "\\0"))
newtab = '\0';