Subject: Re: rc.subr don't check rcvar YES except at boot/shutdown
To: Jeremy C. Reed <reed@reedmedia.net>
From: Lubomir Sedlacik <salo@Xtrmntr.org>
List: tech-userlevel
Date: 02/15/2007 01:46:04
--VOAkKSXG6MhRWuAn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Feb 13, 2007 at 12:46:02PM -0600, Jeremy C. Reed wrote:
> s/onestart/one${rc_arg}/
> So it won't suggest "onestart" when you want "status".
> Also do we want these messages logged?
> Maybe instead of warn use echo 1>&2
now it also checks whether the keyword actually makes sense, otherwise
just prints usage. unfortunatelly, the two lines got quite long..
i don't think it makes sense to turn this into a function, though.
Index: rc.subr
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/etc/rc.subr,v
retrieving revision 1.68
diff -u -p -r1.68 rc.subr
--- rc.subr 27 Jan 2007 14:30:26 -0000 1.68
+++ rc.subr 15 Feb 2007 00:40:38 -0000
@@ -460,10 +460,21 @@ run_rc_command()
# if ${rcvar} is set, and $1 is not
# "rcvar", then run
# checkyesno ${rcvar}
- # and return if that failed
+ # and return if that failed or warn
+ # user and exit when interactive
#
if [ -n "${rcvar}" -a "$rc_arg" !=3D "rcvar" ]; then
if ! checkyesno ${rcvar}; then
+ if [ -z $_run_rc_script ]; then
+ for _elem in $_keywords; do
+ if [ "$_elem" =3D "$rc_arg" ]; then
+ echo 1>&2 "\$${rcvar} is not enabled - see ${rcvar_manpage}."
+ echo 1>&2 "Use '${name} one${rc_arg}' if you really mean it."
+ exit 1
+ fi
+ done
+ rc_usage "$_keywords"
+ fi
return 0
fi
fi
@@ -704,6 +715,8 @@ $command $rc_flags $command_args"
#
run_rc_script()
{
+ _run_rc_script=3Dtrue
+
_file=3D$1
_arg=3D$2
if [ -z "$_file" -o -z "$_arg" ]; then
--=20
-- Lubomir Sedlacik <salo@{NetBSD,Xtrmntr,silcnet}.org> --
--VOAkKSXG6MhRWuAn
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (NetBSD)
iD8DBQFF061LiwjDDlS8cmMRAhEiAJ0VbJuKi8+WDnCugojteOdFvx+KaACeLmXu
zY439N4JNLDfxTuEZxFQCkA=
=TRnK
-----END PGP SIGNATURE-----
--VOAkKSXG6MhRWuAn--