On Wed, Aug 24, 2005 at 05:22:32PM +0100, Andrew Porter wrote:
/usr/sbin/mysqld --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
is harder to read than
/usr/sbin/mysqld --print-defaults |
sed -ne "s/^.*--$1=\\([^ ]\\+\\).*\$/\\1/p"
Both require knowledge of a particular tools - one only one tool
though.
that's not completely true, unless knowledge of sed also implies a good
understanding of posix regular expressions, in which case i wouldn't be
so hasty to claim it was easier to understand.
however, all of this notwithstanding, if someone takes the time to
submit a patch similar to this it will probably be included.
Of course this would all be so much simpler if we could actually use
the
power of modern shells (post 1993) in init scripts - subprocesses
wouldn't be required at all....
it is a /bin/bash script, so i suppose bashisms are allowed, provided
that there aren't other reasons christian or i would object to them.