Skip to content

Instantly share code, notes, and snippets.

@h1ros
Last active May 5, 2018 22:59
Show Gist options
  • Save h1ros/e09a41ab5ba5eba686fabe0198442271 to your computer and use it in GitHub Desktop.
Save h1ros/e09a41ab5ba5eba686fabe0198442271 to your computer and use it in GitHub Desktop.
Remove duplicated path in LD_LIBRARY_PATH
if [ -n "$LD_LIBRARY_PATH" ]; then
old_PATH=$LD_LIBRARY_PATH:; LD_LIBRARY_PATH=
while [ -n "$old_PATH" ]; do
x=${old_PATH%%:*} # the first remaining entry
case $LD_LIBRARY_PATH: in
*:"$x":*) ;; # already there
*) LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$x;; # not there yet
esac
old_PATH=${old_PATH#*:}
done
LD_LIBRARY_PATH=${LD_LIBRARY_PATH#:}
unset old_PATH x
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment