In article <[EMAIL PROTECTED]>, Marc Chantreux <[EMAIL PROTECTED]> wrote: >there are a lot of things in /etc/init.d/*, and {pre,post}inst >scripts that can be rewritten more efficiently ( i think ). > >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#*=} >} > >that are not bugs so i wonder if package maintainers where pleased if i >reportbug those lines as wishlist.
Make sure you use only POSIX features when doing this. I think "grep -o" is a GNU extension, FreeBSD doesn't have it for example. 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" } Mike. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]