Skip to content
Snippets Groups Projects
Commit 50ccb197 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: fix bad environment parsing in foamCreateModuleInclude

- The changes in foamCleanPath introduced for issues (#1007, #1008)
  include quoted output of the cleaned environment variable.
  When used in foamCreateModuleInclude, the quotes make their way
  into the final environment. Avoid this by using the -sh-env
  eval format instead.

- add environment extraction of MANPATH changes
parent 31c21031
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
# \\/ M anipulation | Copyright (C) 2016-2017 CINECA # \\/ M anipulation | Copyright (C) 2016-2017 CINECA
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
...@@ -40,7 +40,7 @@ options: ...@@ -40,7 +40,7 @@ options:
-output=file The output name (default: ModuleInclude.tcl) -output=file The output name (default: ModuleInclude.tcl)
-preload=file Specify (module) file to preload. Can use multiple times -preload=file Specify (module) file to preload. Can use multiple times
-tmpdir=file The tmp directory to use. -tmpdir=file The tmp directory to use.
-help print the usage -help Print the usage
Create module settings for inclusion in a top-level openfoam module. Create module settings for inclusion in a top-level openfoam module.
...@@ -136,11 +136,12 @@ then ...@@ -136,11 +136,12 @@ then
done done
# Call itself with clean environment. # Call itself with clean environment.
# Tag the start/end of the original PATH, LD_LIBRARY_PATH # Tag the start/end of the original PATH, MANPATH, LD_LIBRARY_PATH
exec env -i \ exec env -i \
HOME=$HOME \ HOME=$HOME \
USER=$USER \ USER=$USER \
PATH=":MOD_PREPEND:$(syspath $PATH):MOD_APPEND:" \ PATH=":MOD_PREPEND:$(syspath $PATH):MOD_APPEND:" \
MANPATH=":MOD_PREPEND:$(syspath $MANPATH):MOD_APPEND:" \
LD_LIBRARY_PATH=":MOD_PREPEND:$(syspath $LD_LIBRARY_PATH):MOD_APPEND:" \ LD_LIBRARY_PATH=":MOD_PREPEND:$(syspath $LD_LIBRARY_PATH):MOD_APPEND:" \
$0 \ $0 \
--recursive-backend-- \ --recursive-backend-- \
...@@ -232,16 +233,14 @@ foamClean=$WM_PROJECT_DIR/bin/foamCleanPath ...@@ -232,16 +233,14 @@ foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
if [ -x "$foamClean" ] if [ -x "$foamClean" ]
then then
cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" eval $($foamClean -sh-env=PATH "$foamOldDirs")
cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ eval $($foamClean -sh-env=MANPATH "$foamOldDirs")
&& LD_LIBRARY_PATH="$cleaned" eval $($foamClean -sh-env=LD_LIBRARY_PATH "$foamOldDirs")
# May not have/need any third party at all # May not have/need any third party at all
if [ -n "$FOAM_EXT_LIBBIN" -a ! -d "$FOAM_EXT_LIBBIN" ] if [ -n "$FOAM_EXT_LIBBIN" -a ! -d "$FOAM_EXT_LIBBIN" ]
then then
cleaned=$($foamClean "$LD_LIBRARY_PATH" "$FOAM_EXT_LIBBIN") \ eval $($foamClean -sh-env=LD_LIBRARY_PATH "$FOAM_EXT_LIBBIN")
&& LD_LIBRARY_PATH="$cleaned"
unset FOAM_EXT_LIBBIN unset FOAM_EXT_LIBBIN
fi fi
fi fi
...@@ -296,11 +295,12 @@ diff $tmpFiles.alias.pre.log $tmpFiles.alias.post.log > $tmpFiles.alias.diff.lo ...@@ -296,11 +295,12 @@ diff $tmpFiles.alias.pre.log $tmpFiles.alias.post.log > $tmpFiles.alias.diff.lo
echo "# -------------------" > $moduleOutput echo "# -------------------" > $moduleOutput
# -------------------------------------------------- # --------------------------------------------------
# Environment other than PATH, LD_LIBRARY_PATH # Environment other than PATH, MANPATH, LD_LIBRARY_PATH
echo "# Environment" >> $moduleOutput echo "# Environment" >> $moduleOutput
grep '> ' $tmpFiles.env.diff.log | \ grep '> ' $tmpFiles.env.diff.log | \
sed \ sed \
-e '/^> *PATH=/d' \ -e '/^> *PATH=/d' \
-e '/^> *MANPATH=/d' \
-e '/^> *LD_LIBRARY_PATH=/d' \ -e '/^> *LD_LIBRARY_PATH=/d' \
-e 's/^>/setenv /' \ -e 's/^>/setenv /' \
-e 's/=/ "/' -e 's/$/\"/' >> $moduleOutput -e 's/=/ "/' -e 's/$/\"/' >> $moduleOutput
...@@ -328,6 +328,28 @@ sed \ ...@@ -328,6 +328,28 @@ sed \
$tmpFiles.path.diff.log >> $moduleOutput $tmpFiles.path.diff.log >> $moduleOutput
# -------------------------------------------------- # --------------------------------------------------
# --------------------------------------------------
# Changes in MANPATH - without junk and system directories
echo "# MANPATH" >> $moduleOutput
sed -ne 's/^< *MANPATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.manpath.pre.log
sed -ne 's/^> *MANPATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.manpath.post.log
grep -vxFf $tmpFiles.manpath.pre.log $tmpFiles.manpath.post.log | \
sed \
-e '\@^/usr/share/@d' \
-e '\@^/usr/local/@d' \
-e '\@^/usr/lib@d' \
-e '\@^[.]$@d' \
-e '\@^$@d' \
> $tmpFiles.manpath.diff.log
sed \
-e 's/^/append-path MANPATH "/' \
-e 's/$/\"/' \
$tmpFiles.manpath.diff.log >> $moduleOutput
# --------------------------------------------------
# -------------------------------------------------- # --------------------------------------------------
# Changes in LD_LIBRARY_PATH - without junk and system directories # Changes in LD_LIBRARY_PATH - without junk and system directories
echo "# LD_LIBRARY_PATH" >> $moduleOutput echo "# LD_LIBRARY_PATH" >> $moduleOutput
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment