View Issue Details

IDProjectCategoryView StatusLast Update
00013671003.1(2016/18)/Issue7+TC2Shell and Utilitiespublic2024-06-11 09:08
Reportersteffen Assigned To 
PrioritynormalSeverityEditorialTypeEnhancement Request
Status ClosedResolutionAccepted As Marked 
NameSteffen Nurpmeso
Organization
User Reference
SectionVol. 3: Shell and Utilities, mailx
Page Number2943, 2944
Line Number97431, 97471 ff.
Interp Status---
Final Accepted Text0001367:0005162
Summary0001367: mailx: add -E option to discard (not send) empty messages
DescriptionThe mailx variants of Apple, NetBSD, OpenBSD as well as other Open Source incarnations, support a command line option -E that rejects sending empty messages, successfully.

This is very helpful in scripted use cases since possible error notifications will only be send out if necessary.

The backing value ("INTERNAL VARIABLE") is different (skipemptybody, dontsendempty, skipempty, to name a few), but the behaviour of the -E option itself is identical.

The only known mailx incarnation which does not support -E is Solaris (OpenIndiana inspected), but the implementation is simplicistic since mailx warns on empty messages, the code change would need to turn

  if (fsize(mtf) == 0 && hp->h_subject == NOSTR) {
    printf(gettext("No message !?!\n"));
    goto out;
  }

into

  if (fsize(mtf) == 0) {
    if (value("dontsendempty") != NOSTR)
      goto jout;
    if (hp->h_subject == NOSTR) {
      printf(gettext("No message !?!\n"));
      goto out;
    }
  }
Desired ActionOn page 2943, line 97431, change

  mailx [−s subject] address...

into

  mailx [-E] [−s subject] address...

On page 2944, insert after line 97471

  -E Discard messages with an empty message body, successfully.
Tagsissue8

Relationships

related to 0001368 Closed Unworldly use of redirection and mailx(1) in at(1) and batch(1) examples. 

Activities

geoffclare

2020-07-09 08:01

manager   bugnote:0004895

Last edited: 2020-07-09 08:01

Line 98259 in EXIT STATUS also needs to change. I suggest changing:
Successful completion; note that this status implies that all messages were sent, ...
to:
Successful completion; note that this status implies that all messages were sent, or successfully discarded (see -E), ...


steffen

2020-07-09 13:25

reporter   bugnote:0004896

..and the Solaris / OpenIndiana should allow all-empty messages by default, nothing is wrong with them, they are the shortest possible mail-based notification ("ping"), which in practice is nice since in practice the MTA / LDA (Mail-Transfer-Agent, Local-Delivery-Agent) adds at least a so-called From_, but especially the former also a From: line, for example

  #?0|kent:steffen$ </dev/null mailx -:/ root
  mailx: No message, no subject; hope that's ok
  #?0|kent:steffen$ tail -n 13 /var/spool/mail/steffen

  From steffen@localhost Thu Jul 9 15:22:56 2020
  Received: from steffen (uid 1000)
          (envelope-from steffen@localhost)
          id a791
          by kent (DragonFly Mail Agent v0.13);
          Thu, 09 Jul 2020 15:22:56 +0200
  Date: Thu, 09 Jul 2020 15:22:56 +0200
  To: root
  User-Agent: mailx v14.9.19
  Message-Id: <5f071a30.a791.1071c30e@kent>
  From: <steffen@localhost>

  #?0|kent:steffen$

The BSD based code does

        if (fsize(mtf) == 0) {
                if (value("skipempty") != NULL)
                        goto out;
                if (hp->h_subject == NULL || *hp->h_subject == '\0')
                        puts("No message, no subject; hope that's ok");
                else
                        puts("Null message body; hope that's ok");
        }

Which, finally, and as an off-topic note, makes me think the root of the related issue 0001368 was caused by experiences with SysV based mail.

rhansen

2020-12-10 17:23

manager   bugnote:0005162

On page 2943 line 97431 (mailx SYNOPSIS) change:
<tt>mailx [−s subject] address...</tt>
to:
<tt>mailx [-E] [−s subject] address...</tt>

On page 2944, insert after line 97471:
-E Discard messages with an empty message body.

On page 2964 line 98259 (mailx EXIT STATUS) change:
Successful completion; note that this status implies that all messages were sent, ...
to:
Successful completion; note that in Send Mode this status implies that all messages were either sent or successfully discarded (see -E), ...

geoffclare

2020-12-16 16:41

manager   bugnote:0005182

When applying this bug I also made an editorial change to page 2944 line 97467 from:
(Only the -s subject option shall be required on all systems...
to:
(Only the -E and -s subject options are required on all systems...

Issue History

Date Modified Username Field Change
2020-07-08 22:55 steffen New Issue
2020-07-08 22:55 steffen Name => Steffen Nurpmeso
2020-07-08 22:55 steffen Section => Vol. 3: Shell and Utilities, mailx
2020-07-08 22:55 steffen Page Number => 2943, 2944
2020-07-08 22:55 steffen Line Number => 97431, 97471 ff.
2020-07-09 08:01 geoffclare Note Added: 0004895
2020-07-09 08:01 geoffclare Note Edited: 0004895
2020-07-09 08:02 geoffclare Relationship added related to 0001368
2020-07-09 13:25 steffen Note Added: 0004896
2020-12-10 17:23 rhansen Note Added: 0005162
2020-12-10 17:24 rhansen Interp Status => ---
2020-12-10 17:24 rhansen Final Accepted Text => 0001367:0005162
2020-12-10 17:24 rhansen Status New => Resolved
2020-12-10 17:24 rhansen Resolution Open => Accepted As Marked
2020-12-10 17:24 rhansen Tag Attached: issue8
2020-12-16 16:41 geoffclare Note Added: 0005182
2020-12-16 16:41 geoffclare Status Resolved => Applied
2024-06-11 09:08 agadmin Status Applied => Closed