[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a special variable for the directory where the script is in

From: Bernd Eggink
Subject: Re: Is there a special variable for the directory where the script is in?
Date: Fri, 12 Feb 2010 19:41:36 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv: Gecko/20100111 Thunderbird/3.0.1

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:

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 Eggink

reply via email to

[Prev in Thread] Current Thread [Next in Thread]