On 08/18/2011 09:39 PM, Raphaël Droz wrote: > attached, needs review *Very* unthrorough one below:
> sed -n '/! '"$1"'/{n; :a; /^!/q; p; n;b a;}' ${2:-$files}|awk '{print $1}' How portable is this sed statement? I don't know sed well enough to be able to even read it ;). Maybe it could be optimized to do also what the awk does to get rid of one process? > _runtime_have() { > [[ -z "$1" ]] && return > return $(which "$1" &> /dev/null) > } This function should be just dropped and "type -P" used instead of it. > COMPREPLY=( $( compgen -W "$(sed -n 's/.*xkb_keycodes > "\(.*\)".*/\1/p' $(grep -lrwm1 xkb_keycodes $Xdir/keycodes/*)|sort -u)" -- > "$cur" ) ) > COMPREPLY=( $( compgen -W "$(sed -n 's/.*xkb_geometry > "\(.*\)".*/\1/p' $(grep -lrwm1 xkb_geometry $Xdir/geometry/*)|sort -u)" -- > "$cur" ) ) The -m1 in those greps is not portable but I suppose it is not actually needed with -l, and unfortunately -r is not portable either. Maybe these can be rewritten using "**" and without grep altogether (shopt globstar needs to be in effect temporarily for that)? > _runtime_have xauth && COMPREPLY=( $( compgen -W "$(xauth -n > list|sed -n 's/^[^:]*\(:[0-9]\+\).*/\1/p'|sort -u)" -- "$cur" ) ) > _runtime_have xinput && COMPREPLY=( $( compgen -W "$(xinput list > --short|sed -n '/keyboard/s/.*id=\([0-9]\+\).*/\1/p')" -- "$cur" ) ) The \+ in those seds is not portable. Use \{1,\} instead (and see test/runLint in git). _______________________________________________ Bash-completion-devel mailing list Bash-completion-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel