Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How to safely prepend a directory to a PATH-like variable (in any POSIX-compliant shell):

export LD_LIBRARY_PATH=/opt/whatever/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

Pull request sent to https://github.com/torch/distro/pull/228.



Good fix and good for sending them a merge request.

I still find it kinda baffling glibc would have this behavior for a trailing colon (:). Like, I know it's probably legacy/comparability, but it feels like a security nightmare. ./ should be explicit, not implicit.


Also for leading colons. (but you probably knew that)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: