the mhbuild directive that send(1) will use.
- mhbuild(1) can now encode 8-bit message headers using RFC-2047 encoding
rules.
- The whatnow(1) attach feature will determine the content type of an
- attachment using a program such as file --mime, if available at
+ attachment using a program such as file --mime-type, if available at
configuration time. If not, it will use mhshow-suffix- entries as
- before.
+ before. The -v switch to attach causes it to display the mhbuild
+ directive for an attachformat specied by an optional -a switch.
-----------------
OBSOLETE FEATURES
-.TH WHATNOW %manext1% "December 13, 2013" "%nmhversion%"
+.TH WHATNOW %manext1% "January 12, 2014" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.B ls [ls-options]
list files in the attachment working directory using the ls command
.TP \w'refilezzzzfolderz'u
-.B attach files
-add the named files to the draft as MIME attachments
+.B attach [-v [-a 0|1|2]] files
+add the named files to the message as MIME attachments; -v displays
+the mhbuild directive, using the optionally specified attachformat
+[-a] if that is also provided to
+.IR send (1)
.TP \w'refilezzzzfolderz'u
.B alist [-ln]
list the MIME attachments, either short, long [-l] or numbered [-n]
set -e
case ${whatnowtest} in
- cd) cat > "$expected" <<EOF
+ cd) cat >"$expected" <<EOF
attach $testname_quoted
alist
$testname
alist
EOF
;;
- "") cat > "$expected" <<EOF
+ "") cat >"$expected" <<EOF
$testname
EOF
;;
# whatnow's exit status is always 1 so that is not a failure
set +e
echo "attach $testname_quoted" | \
- run_prog whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+ run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
echo "alist" | \
- run_prog whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+ run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
echo "detach $testname_quoted" | \
- run_prog whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+ run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
echo "alist" | \
- run_prog whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+ run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
set -e
check "$expectederr" "$actualerr"
check "$expected" "$actual"
+cat >"$expected" <<EOF
+
+What now? at
+whatnow: attach command requires file argument(s).
+
+What now? at -v
+whatnow: attach command requires file argument(s).
+
+What now? at -v -a
+whatnow: ignoring attach -a without format argument.
+whatnow: attach command requires file argument(s).
+
+What now? at -v -a 0
+whatnow: attach command requires file argument(s).
+
+What now? at -a
+whatnow: ignoring attach -a without format argument.
+whatnow: attach command requires file argument(s).
+
+What now? at -a -v
+whatnow: ignoring attach -a without format argument.
+whatnow: attach command requires file argument(s).
+
+What now? at -a 0 -v
+whatnow: attach command requires file argument(s).
+
+What now? at -a 0 Mail/context
+
+What now? at -v -a Mail/context
+whatnow: ignoring attach -a without format argument.
+#text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
+
+What now? at -v -a 3 Mail/context
+whatnow: ingoring invalid attachformat value of 3
+#text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
+
+What now? at -v Mail/context
+#text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
+
+What now? at -v -a 1 Mail/context
+#text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
+
+What now? at -v -a 0 Mail/context
+#text/plain; charset=us-ascii; name="context"; x-unix-mode=0644 [ ASCII text ] ${MH_TEST_DIR}/Mail/context
+
+What now? quit -delete
+EOF
+
+set +e
+printf '%s\n' \
+'at' \
+'at -v' \
+'at -v -a' \
+'at -v -a 0' \
+'at -a' \
+'at -a -v' \
+'at -a 0 -v' \
+'at -a 0 Mail/context' \
+'at -v -a Mail/context' \
+'at -v -a 3 Mail/context' \
+'at -v Mail/context' \
+'at -v -a 1 Mail/context' \
+'at -v -a 0 Mail/context' \
+'quit -delete' | whatnow >$actual 2>&1
+set -e
+
+check "$expected" "$actual"
+
test ${failed:-0} -eq 0 && rm "$testname"
exit $failed
* pwd command and exists to allow the user
* to verify the directory.
*
- * attach files This option attaches the named files to
- * the draft.
+ * attach [-v [-a 0|1|2]] files
+ * This option attaches the named files to
+ * the draft. -v displays the mhbuild
+ * directive, using the optionally specified
+ * attachformat [-a] if that is also provided
+ * to send(1).
*
* alist [-ln] This option lists the attachments on the
* draft. -l gets long listings, -n gets
X("cd [directory]", 0, CDCMDSW) \
X("pwd", 0, PWDCMDSW) \
X("ls", 2, LSCMDSW) \
- X("attach", 0, ATTACHCMDSW) \
+ X("attach [-v [-a 0|1|2]]", 0, ATTACHCMDSW) \
X("detach [-n]", 0, DETACHCMDSW) \
X("alist [-ln] ", 2, ALISTCMDSW) \
break;
- case ATTACHCMDSW:
+ case ATTACHCMDSW: {
/*
* Attach files to current draft.
*/
+ int verbose = 0;
+ int attachformat = 1;
+ char **ap;
+
if (attach == (char *)0) {
advise((char *)0, "can't attach because no header field name was given.");
break;
}
+ for (ap = argp+1; *ap; ++ap) {
+ if (strcmp(*ap, "-v") == 0) {
+ ++argp;
+ verbose = 1;
+ } else if (strcmp(*ap, "-a") == 0) {
+ ++argp;
+ if (*(ap+1) == NULL ||
+ ! isdigit ((unsigned char) *(ap+1)[0])) {
+ advise(NULL,
+ "ignoring attach -a without format argument.");
+ } else {
+ ++argp;
+ ++ap;
+ if ((attachformat = atoi(*ap)) > 2) {
+ advise(NULL,
+ "ingoring invalid attachformat value of %d",
+ attachformat);
+ attachformat = 1;
+ }
+ }
+ } else if (*ap[0] != '-') {
+ break;
+ }
+ }
+
if (*(argp+1) == (char *)0) {
- advise((char *)0, "attach command requires file argument(s).");
+ advise(NULL, "attach command requires file argument(s).");
break;
}
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
while (fgets(shell, sizeof (shell), f) != (char *)0) {
+ char *build_directive;
+
*(strchr(shell, '\n')) = '\0';
- if (*shell == '/')
+ if (*shell == '/') {
(void)annotate(drft, attach, shell, 1, 0, -2, 1);
- else {
+ if (verbose) {
+ build_directive =
+ construct_build_directive (shell, NULL,
+ attachformat);
+ }
+ } else {
(void)sprintf(file, "%s/%s", cwd, shell);
(void)annotate(drft, attach, file, 1, 0, -2, 1);
+ if (verbose) {
+ build_directive =
+ construct_build_directive (file, NULL,
+ attachformat);
+ }
+ }
+
+ if (verbose) {
+ printf ("%s", build_directive);
+ free (build_directive);
}
}
}
break;
-
+ }
case DETACHCMDSW:
/*
* Detach files from current draft.