Joerg Sonnenberger wrote:
On Sun, Jul 20, 2008 at 04:26:47AM +0200, Christian Biere wrote:+cat "${userfile}" __CONF_FILE__ __DB_FILE__ 2>/dev/null | \ +{ + while read line + do + line="${line##\#*}"+ prog="${line%%\ *}" + if [ X != "X${prog}" ] && [ -x "${prog}" ]+ then exec ${line} "${@}" + fi + doneCan you make this awk please? read is horrible slow for larger files... Joerg
Please see attached... Not sure if getline is any faster than read, though. Louis
--- pkgtools/pkg_alternatives/files/wrapper.sh.orig 2008-07-21
08:17:07.000000000 -0400
+++ pkgtools/pkg_alternatives/files/wrapper.sh 2008-07-21 09:15:15.000000000
-0400
@@ -44,16 +44,16 @@
else
userfile=~/.pkg_alternatives/${wrapper}
fi
-alternatives=$(cat ${userfile} __CONF_FILE__ __DB_FILE__ 2>/dev/null | \
- grep -v "^#" | tr ' ' '¬')
found=
-for a in ${alternatives}; do
- prog=$(echo ${a} | cut -d '¬' -f 1)
- if [ -x ${prog} ]; then
- found=$(echo ${a} | tr '¬' ' ')
- break
- fi
+for f in $userfile __CONF_FILE__ __DB_FILE__ ;do
+ [ -f "$f" ] && {
+ found=$(awk '!/^#/{
+ "if [ -x " $1 " ] ; then echo " $0 " ;fi " | getline found
+ print found
+ }' $f)
+ }
+ [ -n "$found" ] && break
done
if [ -z "${found}" ]; then