On Friday 13 February 2015 10:16:34 Richard W.M. Jones wrote:
Add a bash function 'prepend' for intelligently prepending elements to paths. eg:
prepend PYTHONPATH "/foo"
would set PYTHONPATH to "/foo" or "/foo:<previous-contents-of-PYTHONPATH>"
Tested by:
(1) Building and testing libguestfs twice: first without libguestfs installed as a system library, and then with it installed.
(2) Examining the output of './run printenv' by hand and comparing environment variables to the expected values. ---
Nice idea, thanks for it.
# Set LD_LIBRARY_PATH and DYLD_LIBRARY_PATH to contain library. -build_libs_path="$b/src/.libs:$b/java/.libs:$b/gobject/.libs" -export LD_LIBRARY_PATH="$build_libs_path${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" -export DYLD_LIBRARY_PATH="$build_libs_path${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH" +prepend LD_LIBRARY_PATH "$b/gobject/.libs" +prepend LD_LIBRARY_PATH "$b/java/.libs" +prepend LD_LIBRARY_PATH "$b/src/.libs" +prepend DYLD_LIBRARY_PATH "$b/gobject/.libs" +prepend DYLD_LIBRARY_PATH "$b/java/.libs" +prepend DYLD_LIBRARY_PATH "$b/src/.libs" +export LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH
I'd still leave the build_libs_path variable, so we don't duplicate its content twice.
# virt-p2v-make-* data directory. if [ -z "$VIRT_P2V_DATA_DIR" ]; then - VIRT_P2V_DATA_DIR="$b/p2v" + prepend VIRT_P2V_DATA_DIR "$b/p2v" export VIRT_P2V_DATA_DIR fi
Is prepend needed here? After all, it is just a single directory.
# For Lua. export LUA=@LUA@ +# Can't use 'prepend' here because Lua paths use semicolons. if [ -z "$LUA_CPATH" ]; then LUA_CPATH="$b/lua/?.so" else
I guess using a second helper like: prepend_semicolon() { eval $1="$2\${$1:+;\$$1}" } could help? -- Pino Toscano