hi again folks -

one more patch.  i found i was hankering for a friendlier, more
shell-like `echo' command in comsatd's .biffrc files, and after poking
around in the argcv functions i realised it would be pretty easy to
do.  rather than having to quote a single string, use \n, and make
sure to continue lines with a trailing \, i thought it would be much
prettier if i could just write what looks like a regular shell script.

so the attached patch (when combined with my last one
(mailutils-1.0-escape-fix-0.1.patch - without that this won't work
perfectly) allows me to write my .biffrc like this:

echo
echo New mail for [EMAIL PROTECTED]:
echo ---
echo From: $H{From}
echo Subject: $H{Subject}
echo $B(,5)---

the old-style fully-quoted construction will still work, the only
backwards-incompatibility being that an extra newline will be
appended.  this seems pretty minor to me, so hopefully it won't be an
issue for anyone.

quoting of course also works:

echo "Quoted    extra    spaces"

and it also recognises -n as the first parameter, like the shell
`echo':

echo -n No newline after this line.

this also has the advantage that arguments beyond the first to the
`echo' command are no longer just silently ignored; before, without
quoting, doing something like:

echo New mail for $u

would have just printed `New' to the terminal, which was rather
confusing if you intuitively went for shell syntax.

would people be willing to merge this, along with the fixes previously
posted?

-damon
--- mailutils-1.0.orig/comsat/action.c  2005-08-29 03:21:54.000000000 -0700
+++ mailutils-1.0/comsat/action.c       2006-08-25 15:39:41.000000000 -0700
@@ -369,7 +369,24 @@
            }
          else if (strcmp (argv[0], "echo") == 0)
            {
-             action_echo (tty, cr, argv[1]);
+              int newline = 1;
+              if (argc > 1)
+                {
+                  int c = 1;
+                  if (strcmp (argv[1], "-n") == 0)
+                    {
+                      newline = 0;
+                      c++;
+                    }
+                  for (; c < argc; c++)
+                    {
+                      action_echo (tty, cr, argv[c]);
+                      if (c < argc - 1)
+                        action_echo (tty, cr, " ");
+                    }
+                }
+              if (newline)
+                action_echo (tty, cr, "\n");
              nact++;
            }
          else if (strcmp (argv[0], "exec") == 0)
_______________________________________________
Bug-mailutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-mailutils

Reply via email to