[X-Unix] Login Hooks running items on login a little bit too
quickly
Juan Manuel Palacios
jmpalaciosp at eml.cc
Mon Jan 10 08:15:04 PST 2005
On Jan 10, 2005, at 10:53 AM, Steven Palm wrote:
>
> On Jan 10, 2005, at 8:36 AM, Our PAl Al wrote:
>> Don't quite fully understand it but I think I can still use it.
>>
>> Why do you have the [] around the F in Finder? When I use that line,
>> it doesn't work. ps -ax | grep Finder (without the [] ) works fine.
>
> Strange, it should... It does work here as well. The [] denote a
> "set" of characters, but in this case there is only one so there's no
> reason to use it. I suspect it may have been [Ff]inder at some point,
> matching upper or lower case F in front of inder. But I'd probably
> just use grep -i finder in that case, and let it find any combination
> of upper and lower case. But you always have to be careful to only
> match what you REALLY want so something else doesn't trip you up.
>
The purpose of the [ ] around the first letter of Finder is precisely
to limit the range of matching options of the regular expression. Take
a look:
$[juan at PowerBook: dports](194/0,1)-> ps -ax | grep Finder
412 ?? S 1:00.50
/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
-psn_0_786433
6105 std S+ 0:00.00 grep Finder
Here the range is open, and all instances of "Finder" are matched,
including the search itself. With the [ ] around the F the story is
different:
$[juan at PowerBook: dports](195/0,1)-> ps -ax | grep [F]inder
412 ?? S 1:00.50
/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
-psn_0_786433
Only what we're looking for is matched. To get this behavior without
the [ ] we'd need another, inverse, matching pattern to eliminate
"grep" from the search results:
$[juan at PowerBook: dports](196/0,1)-> ps -ax | grep Finder | grep -v grep
412 ?? S 1:00.50
/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
-psn_0_786433
Now, as to the effect of these differences on the result of $? I think
you're safe whether you decide to use [F]inder or Finder, in both cases
$? == 0 is returned, which is what you need for your script. But in any
case it's usually a good practice to design search patterns that will
return exactly what you're looking for, unless you're explicitly trying
to write a wide as possible pattern to get as many matches as possible.
But that is not the current case.
Hope that makes it a bit clearer. Regards,...
Juan
More information about the X-Unix
mailing list