Am 12.02.2010 15:39, schrieb Greg Wooledge:
On Fri, Feb 12, 2010 at 02:53:39PM +0100, Bernd Eggink wrote:
I once wrote a more generic shell function for this purpose, see:
http://sudrala.de/en_d/shell-getlink.html
You note that it doesn't handle names containing ->, which is true.
I'll get back to that at the end.
It also won't handle any name that "ls -l" will refuse to print out
correctly on any given system.
Also, there are three more cases that it can't handle. The first is
due to missing quotes in your command:
echo ${link##*-> }
Without quotes, this will mangle all leading, trailing or repeated
whitespace. Easily fixed by adding the quotes. (There are a few
other cases of missing quotes too.)
Thanks. I knew there were some missing cases, but when I wrote it, I
didn't consider hardening the function against insane filenames worth
the effort.
However, it now begins to interest me if this is common practice. How
big is the probability to stumble upon such filenames is in real life?
Bernd
--
Bernd Eggink
http://sudrala.de