[vcsh] hook system for vcsh

Richard Hartmann richih.mailinglist at gmail.com
Mon Jan 9 12:40:56 CET 2012

On Mon, Jan 9, 2012 at 10:34, Dieter Plaetinck <dieter at plaetinck.be> wrote:

> setting executable flag to make it become sourced seems weird.
> especially because +x is not even needed if it's sourced.
> i would say merely the fact that a file is stored within
> $XDG_CONFIG_HOME/vcsh/hook.d/init/ qualifies it as a hook. nothing more
> is needed. no +x flag.

If it's executed, +x makes sense, if sourced, +x is not needed.

I am still not sure if sourcing or executing makes more sense. I
really dislike sourcing for security reasons, but I need to do that
for the config, anyway.

> if [ "$VCSH_REPO_NAME" = "vcsh" ]; then... fi

That does not scale well and runs counter to one of the main design
decisions: Pick and mix whatever repos you want.

> the fact that hooks are sourced (vs executed) is very powerful, it
> gives the hook access to everything going on within vcsh. (all vars,
> all defined functions, etc)

vcsh exports all/most things anyway so variables would be OK either
way. I am not sure if functions are really needed in hooks. If they
are, sourcing or refactoring into a library (I know you would not
complain about that) are both valid approaches.

> what are foo and bar? different files, so the $VCSH_HOOK_D/init file sources those 2 files?

Yes, stacking of hooks may be something useful to be able to do.


More information about the vcs-home mailing list