Subject: bug#54625: closed (Re: bug#54625: Why do I need to specify `-o auto` for join's `-e` option to work?)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 29 Mar 2022 15:38:02 +0000

Your bug report

#54625: Why do I need to specify `-o auto` for join's `-e` option to work?

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
54625: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=54625
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#54625: Why do I need to specify `-o auto` for join's `-e` option to work?
From: Pádraig Brady <[email-masked]>
To: Iago-lito <[email-masked]>, [email-masked]
Date: Tue, 29 Mar 2022 16:36:57 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On 29/03/2022 09:07, Iago-lito wrote:
> Hello,
> 
>       This is a follow-up to this (yet) unanswered post on SE U&L:
> https://unix.stackexchange.com/q/696259/87656, which I'm cross-posting
> here. Don't hesitate to fire if it's the wrong place.
> 
> With the following two simple files:
> 
> |a.txt|
> 
> |1 a 2 b 5 c |
> 
> |b.txt|
> 
> |2 x 4 y 5 z |
> 
> The following command does not behave like expected:
> 
> |$ join -a 1 -a 2 -e 0 a.txt b.txt 1 a 2 b x 4 y 5 c z |
> 
> I would expect the option |-e 0| to fill up missing values with zeroes.
> However, the following does work:
> 
> |$ join -a 1 -a 2 -e 0 -o auto a.txt b.txt 1 a 0 2 b x 4 0 y 5 c z |
> 
> Reading documentation from |$ man join|, I see no connection between
> |-o| and |-e| that would make the above behaviour meaningful. Instead, I
> find it misleading that a useless |-o auto| needs to be inserted into my
> command for |-e 0| to work..
> 
> Is there an explanation, to be clarified in the manpage? Or is it a bug?

The info doc is clearer that the output of missing fields need to be
explicitly enabled, https://www.gnu.org/software/coreutils/join :

   ‘-e STRING’
      Replace those output fields that are missing in the input with
      STRING.  I.e., missing fields specified with the ‘-12jo’ options.
I agree that the man page should mention this also,
which I've done in the attached.

Marking this as done.
thanks,
Pádraig

From 120ce321d5f768c00b9e193af4edd5ccceaa45e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Tue, 29 Mar 2022 16:34:10 +0100
Subject: [PATCH] doc: join: clarify that -e only effective for -12jo fields

* src/join.c (usage): Clarify that -e is not sufficient
to enable output of missing fields from one of the inputs.
Rather the -12jo options are required to explicitly
enable output of those fields.
Fixes https://bugs.gnu.org/54625
---
 src/join.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/join.c b/src/join.c
index 3d62ca43a..f2fd1727b 100644
--- a/src/join.c
+++ b/src/join.c
@@ -206,7 +206,11 @@ When FILE1 or FILE2 (not both) is -, read standard input.\n\
 \n\
   -a FILENUM             also print unpairable lines from file FILENUM, where\n\
                            FILENUM is 1 or 2, corresponding to FILE1 or FILE2\n\
-  -e EMPTY               replace missing input fields with EMPTY\n\
+"), stdout);
+      fputs (_("\
+  -e STRING              replace missing (empty) input fields with STRING;\n\
+                           I.e., missing fields specified with '-12jo' options\
+\n\
 "), stdout);
       fputs (_("\
   -i, --ignore-case      ignore differences in case when comparing fields\n\
-- 
2.26.2

Subject: Why do I need to specify `-o auto` for join's `-e` option to work?
From: Iago-lito <[email-masked]>
To: [email-masked]
Date: Tue, 29 Mar 2022 10:07:08 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

     This is a follow-up to this (yet) unanswered post on SE U&L: 
https://unix.stackexchange.com/q/696259/87656, which I'm cross-posting 
here. Don't hesitate to fire if it's the wrong place.

With the following two simple files:

|a.txt|

|1 a 2 b 5 c |

|b.txt|

|2 x 4 y 5 z |

The following command does not behave like expected:

|$ join -a 1 -a 2 -e 0 a.txt b.txt 1 a 2 b x 4 y 5 c z |

I would expect the option |-e 0| to fill up missing values with zeroes. 
However, the following does work:

|$ join -a 1 -a 2 -e 0 -o auto a.txt b.txt 1 a 0 2 b x 4 0 y 5 c z |

Reading documentation from |$ man join|, I see no connection between 
|-o| and |-e| that would make the above behaviour meaningful. Instead, I 
find it misleading that a useless |-o auto| needs to be inserted into my 
command for |-e 0| to work..

Is there an explanation, to be clarified in the manpage? Or is it a bug?

(btw:

$ join (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel.
)

--
Iago-lito