#738 PR closed: Enhanced the Source function using $SHARE_DIR/$source_file as fallback

Labels: enhancement

jsmeix opened issue at 2015-12-11 13:28:

Now the Source function tries using $SHARE_DIR/$source_file
as fallback if $source_file does not exist so that no longer the
full path is required to include a file from $SHARE_DIR.
E.g. instead of

Source "$SHARE_DIR/wrapup/default/99_copy_logfile.sh"

one can now use

Source "wrapup/default/99_copy_logfile.sh"

and the Source function will automatically fall back
including $SHARE_DIR/wrapup/default/99_copy_logfile.sh
(provided wrapup/default/99_copy_logfile.sh does not exist).

schlomo commented at 2015-12-14 10:28:

Won't this change add a lot of Debug output? Especially if we change the SourceStage() code to actually use the feature?

Another thing: Now this function depends on the pwd of the place where it is called. IMHO this is quite dangerous and IIRC we avoid depending on the pwd in ReaR so far.

In line with this maybe another version of the same idea would solve your problem: If the argument to Source() is a relative path then we prepend $SHARE_DIR and if it is an absolute path then we call it as-is. That way you get your goal of not writing a full path and we still don't depend on the pwd.

What do you think?

jsmeix commented at 2015-12-14 12:16:

@schlomo
I fully agree with your reasoning.
I close this pull request for now and make a different one
according to what you suggested.


[Export of Github issue for rear/rear.]