Re: [dwm] dmenu directory test
On Sun, Jun 15, 2008 at 11:39:38AM +0200, Sander van Dijk wrote: > On 6/14/08, James Turner <[EMAIL PROTECTED]> wrote: > > Doesn't it make more sense to do a test, then just redirect error > > output? > > Then you'd have to test more than your patch does: right now, your > patch only tests if we're dealing with a directory; whether or not the > user running the script has permission to cd into that directory is > not taken in consideration. I agree with the others here that the cd > itself is the safest test. Thanks for the info guys. I see your point, I suppose cd is the best test. -- James Turner BSD Group Consulting http://www.bsdgroup.org
Re: [dwm] dmenu directory test
On 6/14/08, James Turner <[EMAIL PROTECTED]> wrote: > Doesn't it make more sense to do a test, then just redirect error > output? Then you'd have to test more than your patch does: right now, your patch only tests if we're dealing with a directory; whether or not the user running the script has permission to cd into that directory is not taken in consideration. I agree with the others here that the cd itself is the safest test.
Re: [dwm] dmenu directory test
On (14/06/08 16:20), James Turner wrote: > To: dynamic window manager > From: James Turner <[EMAIL PROTECTED]> > Subject: Re: [dwm] dmenu directory test > > On Sat, Jun 14, 2008 at 10:16:03PM +0200, Peter Hartlich wrote: > > Hi, > > > > > [...] I was wondering if it would make sense to add a test in dmenu_path > > > to make sure the directory actually exists before trying to cd into it? > > > > If you're bothered about cd printing an error message, you could just add > > 2>/dev/null to the cd line. > > > > Regards, > > Peter > > Doesn't it make more sense to do a test, then just redirect error > output? That cd itself is sort of test. -Ph -- Premysl "Anydot" Hruby, http://www.redrum.cz/
Re: [dwm] dmenu directory test
> Doesn't it make more sense to do a test, then just redirect error > output? That creates a race condition (the directory could be deleted between test and cd). Note that the rest of the code is only run if cd was successful. Also, test may be an external program. Regards, Peter
Re: [dwm] dmenu directory test
On Sat, Jun 14, 2008 at 10:16:03PM +0200, Peter Hartlich wrote: > Hi, > > > [...] I was wondering if it would make sense to add a test in dmenu_path > > to make sure the directory actually exists before trying to cd into it? > > If you're bothered about cd printing an error message, you could just add > 2>/dev/null to the cd line. > > Regards, > Peter Doesn't it make more sense to do a test, then just redirect error output? -- James Turner BSD Group Consulting http://www.bsdgroup.org
Re: [dwm] dmenu directory test
Hi, > [...] I was wondering if it would make sense to add a test in dmenu_path > to make sure the directory actually exists before trying to cd into it? If you're bothered about cd printing an error message, you could just add 2>/dev/null to the cd line. Regards, Peter
[dwm] dmenu directory test
I just cloned the latest tip for dwm and dmenu. I'm happy to report everything is working great for me. On that note, I was wondering if it would make sense to add a test in dmenu_path to make sure the directory actually exists before trying to cd into it? I know I have $HOME/bin in my $PATH, but on my current machine I don't have that directory created. Attached is a simple tweak to dmenu_path to test if the directory exists. Thanks. -- James Turner BSD Group Consulting http://www.bsdgroup.org --- dmenu_path Sat Jun 14 15:24:14 2008 +++ dmenu_path Sat Jun 14 15:25:27 2008 @@ -14,6 +14,7 @@ if ! uptodate then for dir in $PATH do + test -d "$dir" && cd "$dir" && for file in * do