how to refactor path duplication in .mrconfig section headers?

Pieter Praet pieter at praet.org
Fri Oct 28 18:40:12 CEST 2011


On Fri, 28 Oct 2011 16:42:16 +0100, Adam Spiers <vcs-home at adamspiers.org> wrote:
> If I have multiple repository paths all similar but spread across
> different .mrconfig files, e.g.
> 
> in ~/.mrconfig
> 
>     [.config/mr]
>     checkout = ...
> 
> in ~/.config/mr/config.d/CLI:
> 
>     [$HOME/.git-repos/zsh]
>     ...
> 
>     [$HOME/.git-repos/mutt]
>     ...
> 
> and in ~/.config/mr/config.d/GUI:
> 
>     [$HOME/.git-repos/urxvt]
>     ...
> 
>     [$HOME/.git-repos/fonts]
>     ...
> 
> then the DRY fascist inside me is irked by the duplication.  I'd much
> rather write this in ~/.mrconfig:
> 
>     [DEFAULT]
>     lib = MR_GIT=$HOME/.git-repos
> 
>     [.config/mr]
>     checkout = ...
> 
> and then ~/.config/mr/config.d/CLI would have:
> 
>     [$MR_GIT/zsh]
>     ...
> 
>     [$MR_GIT/mutt]
>     ...
> 
> and in ~/.config/mr/config.d/GUI:
> 
>     [$MR_GIT/urxvt]
>     ...
> 
>     [$MR_GIT/fonts]
>     ...
> 
> However this doesn't work - I'm guessing that variable expansion in
> the section headers is done in Perl, so is not influenced by the
> shell-code in the DEFAULT lib?
> 
> So is there any other way of avoiding this duplication?

This should do the trick:

  [DEFAULT]
  lib = export MR_GIT=$HOME/.git-repos
        ^^^^^^


> Thanks,
> Adam
> _______________________________________________
> vcs-home mailing list
> vcs-home at lists.madduck.net
> http://lists.madduck.net/listinfo/vcs-home


Peace

-- 
Pieter


More information about the vcs-home mailing list