output format from the first line in each file, to ensure
the same number of fields are output for each line.
+** Changes in behavior
+
+ join no longer reports disorder when one of the files is empty.
+ This allows one to use join as a field extractor like:
+ join -a1 -o 1.3,1.1 - /dev/null
+
* Noteworthy changes in release 8.9 (2011-01-04) [stable]
@macro checkOrderOption{cmd}
If the @option{--check-order} option is given, unsorted inputs will
cause a fatal error message. If the option @option{--nocheck-order}
-is given, unsorted inputs will never cause an error message. If
-neither of these options is given, wrongly sorted inputs are diagnosed
-only if an input file is found to contain unpairable lines. If an
-input file is diagnosed as being unsorted, the @command{\cmd\} command
-will exit with a nonzero status (and the output should not be used).
+is given, unsorted inputs will never cause an error message. If neither
+of these options is given, wrongly sorted inputs are diagnosed
+only if an input file is found to contain unpairable
+@ifset JOIN_COMMAND
+lines, and when both input files are non empty.
+@end ifset
+@ifclear JOIN_COMMAND
+lines.
+@end ifclear
+If an input file is diagnosed as being unsorted, the @command{\cmd\}
+command will exit with a nonzero status (and the output should not be used).
Forcing @command{\cmd\} to process wrongly sorted input files
containing unpairable lines by specifying @option{--nocheck-order} is
b b1 b2
@end example
+@set JOIN_COMMAND
@checkOrderOption{join}
+@clear JOIN_COMMAND
The defaults are:
@itemize
seq2.count = 0;
}
- /* If the user did not specify --check-order, then we read the
+ /* If the user did not specify --nocheck-order, then we read the
tail ends of both inputs to verify that they are in order. We
skip the rest of the tail once we have issued a warning for that
file, unless we actually need to print the unpairable lines. */
{
if (print_unpairables_1)
prjoin (seq1.lines[0], &uni_blank);
- seen_unpairable = true;
+ if (seq2.count)
+ seen_unpairable = true;
while (get_line (fp1, &line, 1))
{
if (print_unpairables_1)
{
if (print_unpairables_2)
prjoin (&uni_blank, seq2.lines[0]);
- seen_unpairable = true;
+ if (seq1.count)
+ seen_unpairable = true;
while (get_line (fp2, &line, 2))
{
if (print_unpairables_2)
# Before 6.10.143, this would mistakenly fail with the diagnostic:
# join: File 1 is not in sorted order
-['chkodr-7', '-12', ["2 a\n1 b\n", ""], "", 0],
+['chkodr-7', '-12', ["2 a\n1 b\n", "2 c\n1 d"], "", 0],
+
+# After 8.9, join doesn't report disorder by default
+# when comparing against an empty input file.
+['chkodr-8', '', ["2 a\n1 b\n", ""], "", 0],
# Test '--header' feature
['header-1', '--header',