Port of "service" command
Doug Barton
dougb at FreeBSD.org
Tue Jun 9 19:30:51 UTC 2009
Kevin Downey wrote:
> I have a similar shell function I am rather fond of:
>
> rc(){
> find /etc/rc.d/"$1" /usr/local/etc/rc.d/"$1" -exec sudo {} `echo
> "$*"|cut -f 2- -d \ ` \;
> }
Wow, that's painful. :) The only reason you don't notice how painful
is because those two directories have only a few files. Much much more
efficient would be something like:
rc () {
local script=$1
shift
if [ -x "/etc/rc.d/$script" ]; then
/etc/rc.d/$script $*
elif [ -x "/usr/local/etc/rc.d/$script" ]; then
/usr/local/etc/rc.d/$script $*
else
echo "$script does not exist in /etc/rc.d or"
echo "/usr/local/etc/rc.d"
return 1
fi
}
hth,
Doug
--
This .signature sanitized for your protection
More information about the freebsd-ports
mailing list