[Pacemaker] [patch v2] low: remove various bashisms

Dejan Muhamedagic dejanmm at fastmail.fm
Tue Jul 13 10:03:49 EDT 2010


Hi Horms,

This patch was pushed to the stable-1.0 repository. BTW, the
ocf-tester part was not, because it lives in agents, and anyway
that particular line got changed in the meantime. I guess that
you need to do update -C tip.

Cheers,

Dejan

On Mon, Jul 12, 2010 at 06:02:31PM +0900, Simon Horman wrote:
> # HG changeset patch
> # User Simon Horman <horms at verge.net.au>
> # Date 1278925288 -32400
> # Node ID e78d5591acbc9b76e85d8e31b410dea5bfe8e574
> # Parent  110d056193472fa64ffabd3069d5ed20d32b01c2
> low: remove various bashisms
> 
> ---
> 
> v2
> Address concerns raised by Dejan Muhamedagic
> * Use awk -F'; ' instead of awk 'BEGIN {FS="; "}'
> * Drop unnecessary change to counting of processors
> 
> diff -r 110d05619347 -r e78d5591acbc ConfigureMe
> --- a/ConfigureMe	Thu Jul 08 15:06:00 2010 +0900
> +++ b/ConfigureMe	Mon Jul 12 18:01:28 2010 +0900
> @@ -294,7 +294,7 @@
>  	;;
>    distcheck)			
>    	do_configure $FLAGS $@ && \
> -	source ./heartbeat/lib/ha_config && \
> +	. ./heartbeat/lib/ha_config && \
>  	Run $MAKE_CMD DESTDIR="$PWD/heartbeat-$VERSION/=inst" distcheck
>  	;;
>    pkg|package|rpm|deb|dpkg)	
> diff -r 110d05619347 -r e78d5591acbc extra/resources/SysInfo
> --- a/extra/resources/SysInfo	Thu Jul 08 15:06:00 2010 +0900
> +++ b/extra/resources/SysInfo	Mon Jul 12 18:01:28 2010 +0900
> @@ -107,7 +107,7 @@
>  UpdateStat() {
>      name=$1; shift
>      value="$*"
> -    echo -e "$name:\t$value"
> +    printf "%s:\t%s\n" "$name" "$value"
>      ${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -S status -n $name -v "$value"
>  }
>  
> @@ -123,18 +123,14 @@
>  	    mem=`SysInfo_mem_units $mem`
>  	    mem_used=`SysInfo_mem_units $mem_used`
>  	    mem_total=`expr $mem_used + $mem`
> -	    cpu_type=`system_profiler SPHardwareDataType | grep "CPU Type:"`
> -	    cpu_type=${cpu_type/*: /}
> -	    cpu_speed=`system_profiler SPHardwareDataType | grep "CPU Speed:" | awk '{print $3}'`
> -	    cpu_cores=`system_profiler SPHardwareDataType | grep "Number Of"`
> -	    cpu_cores=${cpu_cores/*: /}
> +	    cpu_type=`system_profiler SPHardwareDataType | awk -F': ' '/^CPU Type/ {print $2; exit}'`
> +	    cpu_speed=`system_profiler SPHardwareDataType | awk -F': ' '/^CPU Speed/ {print $2; exit}'`
> +	    cpu_cores=`system_profiler SPHardwareDataType | awk -F': ' '/^Number Of/ {print $2; exit}'`
>  	;;
>  	"Linux")
>  	    if [ -f /proc/cpuinfo ]; then
> -		cpu_type=`grep "model name" /proc/cpuinfo | head -n 1`
> -		cpu_type=${cpu_type/*: /}
> -		cpu_speed=`grep "bogomips" /proc/cpuinfo | head -n 1`
> -		cpu_speed=${cpu_speed/*: /}
> +		cpu_type=`awk -F': ' '/model name/ {print $2; exit}' /proc/cpuinfo`
> +		cpu_speed=`awk -F': ' '/bogomips/ {print $2; exit}' /proc/cpuinfo`
>  		cpu_cores=`grep "^processor" /proc/cpuinfo | wc -l`
>  	    fi
>  
> diff -r 110d05619347 -r e78d5591acbc fencing/test/stonithd_test.sh
> --- a/fencing/test/stonithd_test.sh	Thu Jul 08 15:06:00 2010 +0900
> +++ b/fencing/test/stonithd_test.sh	Mon Jul 12 18:01:28 2010 +0900
> @@ -36,51 +36,51 @@
>  ERR_COUNT=0
>  
>  $LRMADMIN -A myid1 stonith null NULL hostlist=$NODE2
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $LRMADMIN -A myid2 stonith null NULL hostlist=$NODE3
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $LRMADMIN -E myid1 start 0 0 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $LRMADMIN -E myid2 start 0 0 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  
>  $RSH root@$NODE2 $LRMADMIN -A myid3 stonith null NULL hostlist=$NODE1
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $RSH root@$NODE2 $LRMADMIN -A myid4 stonith null NULL hostlist=$NODE3
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $RSH root@$NODE2 $LRMADMIN -E myid3 start 0 0 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $RSH root@$NODE2 $LRMADMIN -E myid4 start 0 0 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  
>  $APITEST 0 $NODE3 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $APITEST 1 $NODE3 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $APITEST 1 $NODE1 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $APITEST 1 $NODE2 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $APITEST 3 $NODE4 4000 2
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  
>  echo "will run test on the $NODE2"
>  
>  $RCP .libs/$APITEST root@$NODE2:
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  
>  $RSH root@$NODE2 $APITEST 0 $NODE3 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $RSH root@$NODE2 $APITEST 1 $NODE3 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $RSH root@$NODE2 $APITEST 1 $NODE1 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $RSH root@$NODE2 $APITEST 1 $NODE2 4000 0
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  $APITEST 2 $NODE4 4000 2
> -[ $? == 0 ] || let ERR_COUNT++ 
> +[ $? = 0 ] || ERR_COUNT=$(($ERR_COUNT+1))
>  
> -if [ $ERR_COUNT == 0 ]; then
> +if [ $ERR_COUNT = 0 ]; then
>  	echo "All tests are ok."
>  else
>  	echo "There are $ERR_COUNT errors."
> diff -r 110d05619347 -r e78d5591acbc tools/hb2openais.sh.in
> --- a/tools/hb2openais.sh.in	Thu Jul 08 15:06:00 2010 +0900
> +++ b/tools/hb2openais.sh.in	Mon Jul 12 18:01:28 2010 +0900
> @@ -351,10 +351,10 @@
>  newstanza() {
>  	do_tabs
>  	printf "%s {\n" $1
> -	let sw=sw+1
> +	sw=$((sw+1))
>  }
>  endstanza() {
> -	let sw=sw-1
> +	sw=$((sw-1))
>  	do_tabs
>  	printf "}\n"
>  }
> @@ -466,7 +466,7 @@
>  	multicastinfo $ring $addr $port
>  	setvalue mcastport $port
>  	setvalue mcastaddr $addr
> -	let ring=$ring+1
> +	ring=$(($ring+1))
>  	endstanza
>  done
>  changemediainfo
> @@ -674,7 +674,7 @@
>  		(cd / && tar cf - $DIST_FILES) |
>  		ssh $ssh_opts $node "rm -f $REMOTE_RM_FILES &&
>  			cd / && tar xf -"
> -		let rc=$rc+$?
> +		rc=$(($rc+$?))
>  	fi
>  done
>  info "Done transfering files"
> diff -r 110d05619347 -r e78d5591acbc tools/ocf-tester.in
> --- a/tools/ocf-tester.in	Thu Jul 08 15:06:00 2010 +0900
> +++ b/tools/ocf-tester.in	Mon Jul 12 18:01:28 2010 +0900
> @@ -44,7 +44,7 @@
>      exit_code=$1; shift
>      if [ $rc -ne $target ]; then
>  	num_errors=`expr $num_errors + 1`
> -	echo -e "* rc=$rc: $msg"
> +	printf "* rc=%s: %s" "$rc" "$msg"
>  	if [ ! -z $exit_code ]; then
>  	    echo "Aborting tests"
>  	    exit $exit_code
> 
> _______________________________________________
> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker




More information about the Pacemaker mailing list