Re: Conditionally include a file in the configuration
* romildo@xxxxxxxxxxx [2004-02-24 09:29 -0300]:
> On Tue, Feb 24, 2004 at 11:27:02AM +0000, Jack Bertram wrote:
> > in .muttrc:
> >
> > source "/path/to/my/conditional/script.sh|"
> > [...]
>
> This is not working with Mutt 1.5.6i.
>
> I have in ~/.mutt/muttrc:
>
> source "~/.mutt/mailboxes.sh|" # mailboxes
>
> When running mutt I get the message:
>
> Error in /home/romildo/.mutt/muttrc, line 161:
> /home/romildo/.mutt/mailboxes.sh|: stat: No such file or directory
That's a known bug in 1.5.6. Updating to the current cvs or applying the
attached patch should help.
Nicolas
? mutt/build
? mutt/stamp-h1
Index: mutt/init.c
===================================================================
RCS file: /home/roessler/cvs/mutt/init.c,v
retrieving revision 3.19
diff -u -r3.19 init.c
--- mutt/init.c 1 Feb 2004 18:00:16 -0000 3.19
+++ mutt/init.c 6 Feb 2004 20:29:08 -0000
@@ -1368,18 +1368,6 @@
char *linebuf = NULL;
size_t buflen;
pid_t pid;
- struct stat s;
-
- if (stat (rcfile, &s) < 0)
- {
- snprintf (err->data, err->dsize, _("%s: stat: %s"), rcfile, strerror
(errno));
- return (-1);
- }
- if (!S_ISREG (s.st_mode))
- {
- snprintf (err->data, err->dsize, _("%s: not a regular file"), rcfile);
- return (-1);
- }
if ((f = mutt_open_read (rcfile, &pid)) == NULL)
{
Index: mutt/muttlib.c
===================================================================
RCS file: /home/roessler/cvs/mutt/muttlib.c,v
retrieving revision 3.18
diff -u -r3.18 muttlib.c
--- mutt/muttlib.c 1 Feb 2004 17:10:43 -0000 3.18
+++ mutt/muttlib.c 6 Feb 2004 20:29:09 -0000
@@ -1134,6 +1134,8 @@
FILE *mutt_open_read (const char *path, pid_t *thepid)
{
FILE *f;
+ struct stat s;
+
int len = mutt_strlen (path);
if (path[len - 1] == '|')
@@ -1149,6 +1151,16 @@
}
else
{
+ if (stat (path, &s) < 0)
+ {
+ mutt_error (_("%s: stat: %s"), path, strerror (errno));
+ return (NULL);
+ }
+ if (!S_ISREG (s.st_mode))
+ {
+ mutt_error (_("%s: not a regular file"), path);
+ return (NULL);
+ }
f = fopen (path, "r");
*thepid = -1;
}