diff --git a/uf b/uf index bde9ba1..28c7aba 100755 --- a/uf +++ b/uf @@ -66,11 +66,11 @@ while [ $# -ne 0 -a "$(expr "$1" : '\(.\).*')" = "-" ]; do done if [ -n "$REVERT" ]; then - awk -v WIDTH=80 ' - /^>/ { print } + gawk -b -O -v WIDTH=80 ' + /^>/ /^[^>]/ { for (i=1;i<=length();i+=WIDTH) { print substr($0,i,WIDTH); } }' "$@" else - awk 'BEGIN { ORS="" } + gawk -b -O 'BEGIN { ORS="" } /^>/ { if (NR!=1) print "\n"; print $0 "\n" } /^[^>]/ { print gensub(/[[:space:]]/,"","g") } END { print "\n" }' "$@" diff --git a/uf-bare b/uf-bare index 0d5a12b..2816c1b 100755 --- a/uf-bare +++ b/uf-bare @@ -48,5 +48,5 @@ while [ $# -ne 0 -a "$(expr "$1" : '\(.\).*')" = "-" ]; do shift done -awk 'NR%2==0' +awk -b -O 'NR%2==0' diff --git a/uf-hdrs b/uf-hdrs index 5cfb219..c251df0 100755 --- a/uf-hdrs +++ b/uf-hdrs @@ -48,5 +48,5 @@ while [ $# -ne 0 -a "$(expr "$1" : '\(.\).*')" = "-" ]; do shift done -awk 'NR%2==1' +awk -b -O 'NR%2==1' diff --git a/uf-map b/uf-map index 05975db..f25d17a 100755 --- a/uf-map +++ b/uf-map @@ -64,5 +64,5 @@ shift # AWK it -awk "NR%2==1 { print }; NR%2==0 { print | \"$OPERATION\" }" +awk -b -O "NR%2==1 { print }; NR%2==0 { print | \"$OPERATION\" }" diff --git a/uf-valid b/uf-valid index 4d3d0bc..cf20c2e 100755 --- a/uf-valid +++ b/uf-valid @@ -157,26 +157,26 @@ done # Do the work -awk -v P="$(basename "$0")" -v WRONG="[^$ALLOW]" -v H=$VAL_HEADERS -v Q=$QUIET -v K=$KEEP_ERRORS -v S=$STOP_ON_ERR -v IGNORECASE=$IGNORE_CASE ' - { ERR = 0 - if ( H && $0 !~ /^>[[:alpha:]]+\|\w+(\|\w+)*(\s+.*)?$/ ) { - print P ": invalid header at line " NR ": " $0 > "/dev/stderr" - ERR = 1 - } - HDR = $0 - getline SEQ - #POS = SEQ ~ WRONG - POS = match (SEQ, WRONG) - if ( POS ) { - print P ": invalid character in sequence at line " NR ", pos " POS ": " substr(SEQ,POS,1) > "/dev/stderr" - ERR = 1 - } - if ( (!ERR || K) && !Q ) { - print HDR - print SEQ - } - if ( ERR && S ) { - exit 1 - } - }' "$@" +awk -b -O -v P="$(basename "$0")" -v WRONG="[^$ALLOW]" -v H=$VAL_HEADERS -v Q=$QUIET -v K=$KEEP_ERRORS -v S=$STOP_ON_ERR -v IGNORECASE=$IGNORE_CASE '{ + ERR = 0 + if ( H && $0 !~ /^>[[:alpha:]]+\|\w+(\|\w+)*(\s+.*)?$/ ) { + print P ": invalid header at line " NR ": " $0 > "/dev/stderr" + ERR = 1 + } + HDR = $0 + getline SEQ + #POS = SEQ ~ WRONG + POS = match (SEQ, WRONG) + if ( POS ) { + print P ": invalid character in sequence at line " NR ", pos " POS ": " substr(SEQ,POS,1) > "/dev/stderr" + ERR = 1 + } + if ( (!ERR || K) && !Q ) { + print HDR + print SEQ + } + if ( ERR && S ) { + exit 1 + } +}' "$@"