On 15Sep2011 10:41, Athanasius <m...@miggy.org> wrote: | On Thu, Sep 15, 2011 at 09:49:14AM +0200, Gérard Robin wrote: | > 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`' | > else | > echo 'set record==OUTBOX/$year/outbox-`date +%m-%y`' | > | > fi | > --------------------------------------------------------- | | The use of '' to enclose the string means bash won't expand any | variables inside. Try "" instead.
Yes. But... | > but if I write the script year.sh like this: [...] | > 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 ? | | Red herring. You're not trying to use $an inside '' in this version. | `` still works inside ''. No. What is actually happening is that in _both_ cases the single quotes in his script are preventing $year _and_ the `command` stuff from happening. In his script! So what is being echoed for mutt to use is _literally_: set record==OUTBOX/$year/outbox-`date +%m-%y` or set record==OUTBOX/`date +%Y`/outbox-`date +%m-%y` Now, in both these cases, mutt _will_ try to expand both $year and the `date...` parts. However, mutt hasn't got a $year to use. The `date...` stuff _does_ work. The second script works because mutt does not try to use $year. | > How to use a variable with mutt ? | Hope this helps. You've been misled by red herrings, alas. Gérard, use Athanasius' suggestion of double quotes in your script. You're not passing $year to mutt, but you will be passing the result you want. Cheers, -- Cameron Simpson <c...@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ The thought of suicide is a comforting one, for with it has come a calm passage through many a bad night. - Fred Nieztsche