![]() ![]() I wasĬompletely shocked to see just how rudimentary it was I've been teaching I totallyįorgot about it until I found myself in need of a similar thing again. So as you can see above, I took a shot at this about 6 months ago. Realpath that can be of some use to someone. I have edited it to address variable scoping by changing it to a subshell function, rather than an inline one. The point of this answer is a portable, POSIX solution. ![]() This answer was previously edited, re-adding the local bashism. So here's an attempt at some reasonable portability (I've checked it with bash as 'sh' and dash), resolving an arbitrary number of symbolic links and it should also work with whitespace in the path(s). While the original question does explicitly ask for a "Bash script", it also makes mention of Mac OS X's BSD-like, non-GNU readlink. In particular, they don't resolve multiple levels of symbolic links, and they are extremely "Bash-y". I found the answer a bit wanting for a few reasons: ![]()
0 Comments
Leave a Reply. |