From 560394b2e6430200f7e236e3a5857a9bfa03df15 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Wed, 28 Jul 2010 19:35:53 +0200 Subject: [PATCH] cosmetics on rfc.sh * more elegant CamelCasing function * use less -F for presenting the usage/help * make 'smart_wrap' useable for standalone reformatting --- admin/rfc.sh | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/admin/rfc.sh b/admin/rfc.sh index 69c37590f..33f8e7a07 100755 --- a/admin/rfc.sh +++ b/admin/rfc.sh @@ -4,7 +4,7 @@ shopt -s extglob function usage() { - less -e <<"EOF" + less -F <<"EOF" Script to maintain Lumiera RFC's usage: @@ -67,16 +67,7 @@ EOF function camel_case() { - local c - local u - local t=" $1" - - for c in {a..z}; do - u=$(tr "a-z" "A-Z" <<<"$c") - t="${t// $c/$u}" - done - - echo "$(tr -c -d "A-Za-z" <<<"$t")" + sed -e 's/[^[:alnum:]]/ /g;s/ \+\(.\)/\U\1/g' <<<" $1" } @@ -418,6 +409,10 @@ wrap) smart_wrap "$file" 80 done ;; +smart_wrap) + # multipurpose smart wrap + smart_wrap "$1" ${2:-80} + ;; help|*) usage ;;