Hoi,

here's more info ...

[2018-10-31 11:21] markus schnalke <mei...@marmaro.de>
> [2018-07-19 10:02] markus schnalke <mei...@marmaro.de>
> > [2018-07-19 03:24] Philipp Takacs <phil...@bureaucracy.de>
> > > [2018-07-18 23:13] Vasilii Kolobkov <polezaivs...@ko5v.net>
> > > > 
> > > > --- a/test/runtest
> > > > +++ b/test/runtest
> > > > @@ -1,13 +1,15 @@
> > > >  #!/bin/sh
> > > >  
> > > >  set -e
> > > >  
> > > >  export MH_TEST_COMMON="$PWD/common.sh"
> > > >  
> > > > +. ${MH_TEST_COMMON}
> > > > +
> > > 
> > > Would be nice if this patch would also remove the source in
> > > the single tests.
> > 
> > I wonder why we haven't done so already? It seems to be pretty
> > obvious to load the helper scripts for all tests during the test
> > setup. Was it initially implemented this way due to
> > time-performance motivation in nmh and we just never thought
> > about it? Or is there another reason? If there is no other reason
> > and the tests work fine with the sourcing in runtest, then we
> > should do as Philipp suggests.
> 
> The thing is: It just doesn't work! ;-)

> Seems that neither of my shells export sourced functions.

There's no way to export functions in portable shell.
        
https://stackoverflow.com/questions/29239806/can-i-export-a-function-in-sh-bourne-shell

The relevant part in POSIX is the section ``Shell Execution
Environment'': Although functions are part of the shell execution
environment, they are not inherited to child environments.
        
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_12

(There are possibilities like `export -f' in some shells, but not
in all, thus it doesn't help us.)


If we really wanted to avoid the sourcing of the common.sh file,
we could store those functions as scripts and add their directory
to PATH for the test scripts. However, I think, sticking with the
current solution of sourcing common.sh is okay.


meillo

Reply via email to