Gérard Robin <[email protected]> writes:

> Hello,
> in order to organize outbox I wrote this script: (year.sh)
>
> ---------------------------------------------------------
> #!/bin/bash
>
> year=`date +%Y`
>
> if [ ! -d ~/Mail/OUTBOX/$year ]
> then  
>       mkdir ~/Mail/OUTBOX/$year
> echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' 
                          ~~~~~~~
I think this variable won't get expanded --- it's inside single quotes.
Try using double quotes instead.

> else
> echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' 
>
> fi
> ---------------------------------------------------------
>
> and in .muttrc I wrote:
>
> source '~/bin/year.sh |'
>
> but it is as if $year did not exist.
> but if I write the script year.sh like this:
>
> ---------------------------------------------------------
> #!/bin/bash
>
> an=`date +%Y`
>
> if [ ! -d ~/Mail/OUTBOX/$an ]
> then  
>       mkdir ~/Mail/OUTBOX/$an
> echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' 
> else
> echo 'set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y`' 
>
> fi
> ---------------------------------------------------------
>
> it works fine.
>
> Why it does not work with $an ?

Explained above.

> How to use a variable with mutt ?

Mutt can read environments, but environment variables are inherited from
the parent process --- probably the shell that you started it.  But this
way, the definition of $year and $an are in a shell forked by mutt, so
the shell can't change the environment variables of their parent
process.

Hope it helps :)

-- 
Carl Lei (XeCycle)
Department of Physics, Shanghai Jiao Tong University
OpenPGP public key: 7795E591
Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591

Attachment: pgpEXm3FDa2y2.pgp
Description: PGP signature

Reply via email to