save and restore PATH and LD_LIBRARY_PATH, so that xdg-open can launch a native executable

This commit is contained in:
Axel Kohlmeyer
2025-07-07 20:21:54 -04:00
parent 5a158d59b4
commit 892c969ee6
3 changed files with 15 additions and 1 deletions

View File

@ -7,6 +7,11 @@ export LC_ALL=C
BASEDIR="$(dirname "$0")"
EXENAME="$(basename "$0")"
# save old settings (for restoring them later)
OLDPATH="${PATH}"
OLDLDLIB="${LD_LIBRARY_PATH}"
# prepend path to find our custom executables
PATH="${BASEDIR}/bin:${PATH}"
# append to LD_LIBRARY_PATH to prefer local (newer) libs
@ -15,6 +20,8 @@ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BASEDIR}/lib"
# set some environment variables for LAMMPS etc.
LAMMPS_POTENTIALS="${BASEDIR}/share/lammps/potentials"
MSI2LMP_LIBRARY="${BASEDIR}/share/lammps/frc_files"
export LD_LIBRARY_PATH LAMMPS_POTENTIALS MSI2LMP_LIBRARY PATH
# export everything
export LD_LIBRARY_PATH LAMMPS_POTENTIALS MSI2LMP_LIBRARY PATH OLDPATH OLDLDLIB
exec "${BASEDIR}/bin/${EXENAME}" "$@"

View File

@ -33,6 +33,11 @@
#
#---------------------------------------------
# restore previously saved environment variables
PATH="${OLDPATH}"
LD_LIBRARY_PATH="${OLDLDLIB}"
export PATH LD_LIBRARY_PATH
NEW_LIBRARY_PATH="/usr/local/lib64"
for s in $(echo $LD_LIBRARY_PATH | sed -e 's/:/ /g')
do \

View File

@ -62,6 +62,8 @@
Add warning dialog at the end of a run if I/O buffer usage is high.
Apply fixes and code modernization suggested by clang-tidy
Make selection of accelerator and threads consistent
Cache and restore PATH and LD_LIBRARY_PATH in linux-wrapper.sh
so that xdg-open can work with native executables
Fix bug when recentering object in image viewer
Fix crash when editing partially quoted strings
Must delete variable when starting a new run, since we don't