Subject: Re: /etc/rc.d scripts and $PATH
To: Peter Seebach <seebs@plethora.net>
From: Greywolf <greywolf@starwolf.com>
List: current-users
Date: 09/15/2003 08:48:39
Thus spake Peter Seebach ("PS> ") sometime Today...
PS> In days of yore, there was no convenient way to access stat(2) from a
PS> command line, so I wrote a utility named, inventively, 'stat'.
PS> So now, if I try to run some rc.d scripts from a prompt, they fail because
PS> my $PATH is wrong. Shouldn't rc.d scripts set their paths to /usr/bin and
PS> /usr/sbin (or whatever) preemptively?
/etc/rc sets the path up, doesn't it? Given that, for rc.d to set their
paths to /sbin:/bin:/usr/sbin:/usr/bin seems redundant.
Is there a reason you're running as super-user without those four
directories first in your $PATH? [Maybe it's just me, but everything
else comes after those.] Does your PATH not get set when you 'su'?
Are you running via 'sudo'?
PS> -s
The other solution would be to put a script called 'spath' [for
"super-user path" or "sane path", your choice]:
#! /bin/sh -
PATH=/sbin:/bin:/usr/sbin:/usr/bin
prog=${1:?"usage: $0 command [ args ... ]"}
shift
exec $prog ${1+"$@"}
--*greywolf;
--
"UNIX does not prevent you from doing stupid things, because then
UNIX would also prevent you from doing clever things." -- Doug Gwyn