Fix sourcing of environment files

Includes "Don't match editor backup files in environment" and "Order
execution of environment.d scripts". These had to be squashed because
the first change alone changes the order env.d scripts are sourced in.

The current glob match for environment files can source editor backup
files (foo.bash~) which will override the real changes you have made.
Other parts use the regex to avoid matching such files, so do
the same for environment file matching.  Note this has to match "."
unlike the other regex, as most env files are "foo.bash"

Also sort the files before sourcing them to ensure a reliable order.
This change should be in line with current expectations, given the
convention is to numerically prefix scripts in this directory.

Update of: I934486b3ff5884063d29c6d9b66fd9b11140464c
Subsumes: Icc509f695d7a15a8026d8c7e463f06acf65499d7
Change-Id: Ibfb562c5970b40598fc95da1e8d4beb9d51d7612
This commit is contained in:
Alexis Lee 2014-07-11 16:50:15 +01:00
parent c9bcce2030
commit 2f6fdb4142

View File

@ -73,7 +73,10 @@ PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX)
ENVIRONMENT_D_DIR=$target_dir/../environment.d
if [ -d $ENVIRONMENT_D_DIR ] ; then
for env_file in $ENVIRONMENT_D_DIR/* ; do
env_files=$(find $ENVIRONMENT_D_DIR -maxdepth 1 -xtype f | \
grep -E "/[0-9A-Za-z_\.-]+$" | \
LANG=C sort -n)
for env_file in $env_files ; do
source $env_file
done
fi