Re: better init.d/* : who carres ?
On Wed, 24 Aug 2005, Miquel van Smoorenburg wrote:
> >for example, in /etc/init.d/mysqld
> >
> >mysqld_get_param() {
> > /usr/sbin/mysqld --print-defaults \
> > | tr " " "\n" \
> > | grep -- "--$1" \
> > | tail -n 1 \
> > | cut -d= -f2
> >}
> >
> >can be written like :
> >
> >mysqld_get_param () {
> > local string=$( /usr/sbin/mysqld --print-defaults | grep -o --
> >"--$1=[^ ]*" )
> > echo ${string#*=}
> >}
>
> So in this case, the solution below is better (and shorter):
>
> mysqld_get_param () {
> /usr/sbin/mysqld --print-defaults |
> sed -ne "s/^.*--$1=\\([^ ]\\+\\).*\$/\\1/p"
> }
And harder to read. Making scripts more complex and harder to read for
some dubious efficiency is not a good idea in my opinion.
--
PGP signed and encrypted | .''`. ** Debian GNU/Linux **
messages preferred. | : :' : The universal
| `. `' Operating System
http://www.palfrader.org/ | `- http://www.debian.org/
Reply to: