On Wed, Oct 15, 2014 at 10:11:18AM +0100, Craig R. Skinner wrote:
> On 2014-10-14 Tue 00:24 AM |, Antoine Jacoutot wrote:
> >
> > Makes sense yes. Not sure I'd want a function just for that one liner
> > though.
> > I'll commit something tomorrow.
> >
>
> Nice one, using shell internals.
>
> This restricts the listing to files which are also executable:
I don't think that's necessary.
> Index: rcctl.sh
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rcctl/rcctl.sh,v
> retrieving revision 1.45
> diff -u -p -r1.45 rcctl.sh
> --- rcctl.sh 15 Oct 2014 07:38:24 -0000 1.45
> +++ rcctl.sh 15 Oct 2014 09:01:35 -0000
> @@ -39,10 +39,12 @@ needs_root()
> ls_rcscripts() {
> local _s
>
> - cd /etc/rc.d && set -- *
> + cd /etc/rc.d || exit
> + set -- *
> for _s; do
> [ "${_s}" = "rc.subr" ] && continue
> - [ ! -d "${_s}" ] && echo "${_s}"
> + [[ -d "${_s}" ]] && continue
> + [[ -f "${_s}" && -x "${_s}" ]] && echo "${_s}"
> done
> }
>
>
--
Antoine