From 630c7d80d48d0ebfe30c2a84d8b887e6b029bc83 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 15:52:40 +0200 Subject: //noise: use BRE @sed --- noise/noise | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/noise/noise b/noise/noise index bd6b17c8..99a08023 100755 --- a/noise/noise +++ b/noise/noise @@ -7,8 +7,8 @@ noise_set() { # set a variable esac case $# in (0) ## print all noise variables - env | sed -rn ' - s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p + env | sed -n ' + s/^noise_\([[:alnum:]_]\+\)=\(.*\)$/\1 = \2/p ' | sort ;; (1) ## print value the specified variable @@ -31,7 +31,9 @@ noise_set() { # set a variable fi ## write variable to $env if grep -q "^$1=" "$env" ; then - sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env + env_cache="`cat $env`" + echo "$env_cache" | + sed "s'^\($1\)=\(.*\)\$'\1=\'$2\''" > $env else echo "$1='$2'" >>$env fi @@ -90,13 +92,13 @@ touch $env ## ## readline() { - { read REPLY && echo "$REPLY" ; } | sed -rn " + { read REPLY && echo "$REPLY" ; } | sed -n " s/[']//g s/~%/\n/g - s/([^\\])([#<>])/\1\\\\\2/g - s:^/([a-z_]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t - s@^([[:alnum:]_/+-]+):[[:space:]]*(.*)@command=lang; args='\1 \2';@p;t - s@^\![[:space:]]*(.*)@command=play; args='\1';@p;t + s/\([^\\]\)\([#<>]\)/\1\\\\\2/g + s:^/\([a-z_]\+\)\([[:space:]]\+\(.*\)\)\?$:command=\1; args='\3';:p;t + s@^\([[:alnum:]_/+-]\+\):[[:space:]]*\(.*\)@command=lang; args='\1 \2';@p;t + s@^\![[:space:]]*\(.*\)@command=play; args='\1';@p;t s:.*:command='$noise_default_command'; args='&';:p;t " } @@ -137,8 +139,8 @@ commit `  Join the 23.shack-dev-team, we've got ` sloccount $dirname/* | - sed -rn ' - s/.*\(SLOC\)[[:space:]]*=[[:space:]]*([0-9]+)$/\1/p + sed -n ' + s/.*(SLOC)[[:space:]]*=[[:space:]]*\([0-9]\+\)$/\1/p '` SLOC, ` { ls $dirname/modules/ -- cgit v1.2.3