Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Jun 2009 12:30:44 -0700
From:      Doug Barton <dougb@FreeBSD.org>
To:        Kevin Downey <redchin@gmail.com>
Cc:        Edwin Shao <eshao@ring0.org>, freebsd-ports@freebsd.org
Subject:   Re: Port of "service" command
Message-ID:  <4A2EB864.1060006@FreeBSD.org>
In-Reply-To: <1d3ed48c0906091140t37fbdd4eq84a1153348db7a53@mail.gmail.com>
References:  <17ca67550906091046t15dfa574i95e432a09e60d379@mail.gmail.com> <1d3ed48c0906091140t37fbdd4eq84a1153348db7a53@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A2EB864.1060006>