Added missing mailx tilde escapes that POSIX wants (~<!, ~a, ~A, ~i).

Updated man page and tilde help file for missing ~ escapes.
Closes PR 782 by Simon J. Gerraty after four years and two weeks.
This commit is contained in:
mjl 1999-02-17 20:48:48 +00:00
parent 1aede0624c
commit fb60b363d0
3 changed files with 116 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: collect.c,v 1.18 1998/12/19 16:31:57 christos Exp $ */
/* $NetBSD: collect.c,v 1.19 1999/02/17 20:48:48 mjl Exp $ */
/*
* Copyright (c) 1980, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
#else
__RCSID("$NetBSD: collect.c,v 1.18 1998/12/19 16:31:57 christos Exp $");
__RCSID("$NetBSD: collect.c,v 1.19 1999/02/17 20:48:48 mjl Exp $");
#endif
#endif /* not lint */
@ -242,6 +242,10 @@ cont:
hadintr++;
collint(SIGINT);
exit(1);
case 'x': /* exit, do not save in dead.letter */
goto err;
case 'h':
/*
* Grab a bunch of headers.
@ -275,6 +279,38 @@ cont:
*/
hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC));
break;
case 'i':
case 'A':
case 'a':
/*
* Insert named variable in message
*/
switch(c) {
case 'i':
cp = &linebuf[2];
while(isspace((unsigned char) *cp))
cp++;
break;
case 'a':
cp = "sign";
break;
case 'A':
cp = "Sign";
break;
default:
goto err;
}
if(*cp && (cp = value(cp)) != NOSTR) {
printf("%s\n", cp);
if(putline(collf, cp, 1) < 0)
goto err;
}
break;
case 'd':
strcpy(linebuf + 2, getdeadletter());
/* fall into . . . */
@ -292,14 +328,53 @@ cont:
printf("Interpolate what file?\n");
break;
}
cp = expand(cp);
if (cp == NOSTR)
break;
if (isdir(cp)) {
if (*cp == '!') { /* insert stdout of command */
extern char *tempEdit;
char *shell;
int nullfd;
int rc;
if((nullfd = open("/dev/null", O_RDONLY, 0)) == -1) {
perror("/dev/null");
break;
}
if ((fbuf = Fopen(tempEdit, "w+")) == NULL) {
perror(tempEdit);
break;
}
(void) unlink(tempEdit);
if ((shell = value("SHELL")) == NOSTR)
shell = _PATH_CSHELL;
rc = run_command(shell, 0, nullfd, fileno(fbuf), "-c", cp+1, NOSTR);
close(nullfd);
if (rc < 0) {
(void) Fclose(fbuf);
break;
}
if (fsize(fbuf) == 0) {
fprintf(stderr, "No bytes from command \"%s\"\n", cp+1);
(void) Fclose(fbuf);
break;
}
rewind(fbuf);
}
else if (isdir(cp)) {
printf("%s: Directory\n", cp);
break;
}
if ((fbuf = Fopen(cp, "r")) == NULL) {
else if ((fbuf = Fopen(cp, "r")) == NULL) {
perror(cp);
break;
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: mail.1,v 1.12 1997/11/11 14:40:14 mrg Exp $
.\" $NetBSD: mail.1,v 1.13 1999/02/17 20:48:48 mjl Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -705,6 +705,10 @@ by the option
.Bl -tag -width Ds
.It Ic \&~! Ns Ar command
Execute the indicated shell command, then return to the message.
.It Ic \&~a
Inserts the autograph string from the sign= option into the message.
.It Ic \&~A
Inserts the autograph string from the Sign= option into the message.
.It Ic \&~b Ns Ar name ...
Add the given names to the list of carbon copy recipients but do not make
the names visible in the Cc: line ("blind" carbon copy).
@ -736,6 +740,8 @@ except all message headers are included.
Edit the message header fields by typing each one in turn and allowing
the user to append text to the end or modify the field by using the
current terminal erase and kill characters.
.It Ic \&~i Ns Ar string
Inserts the value of the named option into the text of the message.
.It Ic \&~m Ns Ar messages
Read the named messages into the message being sent, indented by a
tab or by the value of
@ -760,8 +766,14 @@ Abort the message being sent, copying the message to
in your home directory if
.Ic save
is set.
.It Ic \&~x
Exits as with \&~q, except the message is not saved in dead.letter.
.It Ic \&~r Ns Ar filename
Read the named file into the message.
.It Ic \&~< Ns Ar filename
Reads the named file into the message.
If the argument begins with !,
the rest of the string is taken as an arbitrary system command and is
executed, with the standard output inserted into the message.
.It Ic \&~s Ns Ar string
Cause the named string to become the current subject field.
.It Ic \&~\&t Ns Ar name ...

View File

@ -1,22 +1,34 @@
-----------------------------------------------------------
The following ~ escapes are defined:
~? Print this message
~~ Quote a single tilde
~. Same as .
~h Prompt for to list, subject and cc list
~b users Add users to "blind" cc list
~c users Add users to cc list
~t users Add users to to list
~s subject Set subject
~w file Write message onto file
~d Read in dead.letter
~e Edit the message buffer
~f messages Read in messages
~F messages Same as ~f, but keep all header lines
~h Prompt for to list, subject and cc list
~r file Read a file into the message buffer
~p Print the message buffer
~|command Pipe the message through the command
~^command Same as ~|
~f messages Read in messages
~< file Same as ~f
~<!command Insert the output of command in the message
~i name Insert the value of the named variable
~A Equivalent to iSign
~a Equivalent to isign
~F messages Same as ~f, but keep all header lines
~m messages Read in messages, right shifted by a tab
~M messages Same as ~m, but keep all header lines
~s subject Set subject
~t users Add users to to list
~v Invoke display editor on message
~w file Write message onto file.
~? Print this message
~e Edit the message buffer (using ed or $EDITOR)
~v Invoke display editor (vi or $VISUAL) on message
~p Print the message buffer
~C Dump core
~q Quit, save partial message in dead.letter
~x Quit, do not save dead.letter
~!command Invoke the shell
~|command Pipe the message through the command
~_ mail-cmd Perform the command-level request
~: mail-cmd Same as ~_
-----------------------------------------------------------