From patchwork Sun Nov 11 19:07:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Garrett Cooper X-Patchwork-Id: 1726081 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 9FC60DF288 for ; Sun, 11 Nov 2012 19:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753500Ab2KKTHO (ORCPT ); Sun, 11 Nov 2012 14:07:14 -0500 Received: from mail-da0-f46.google.com ([209.85.210.46]:60366 "EHLO mail-da0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753047Ab2KKTHN (ORCPT ); Sun, 11 Nov 2012 14:07:13 -0500 Received: by mail-da0-f46.google.com with SMTP id n41so2418049dak.19 for ; Sun, 11 Nov 2012 11:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:user-agent:mime-version :content-type; bh=n4olpVON95VcF/k9R40luilyZP2T69uqLjeLTIouSkI=; b=n4RPdEYHZNIWSOz00laXHD8CfKmNvNFP1Mc5wQ9wdDOzvVGgKdvgDfy8DjO2+Q9wgd wrsickydZM7956rJFbGMZXRTcpiNNoRJAnqrfwsTJSVNTQJkGT1/viWyC1zPscaCEVxL /Iurt6kiZUloBTK0vbCwTl1p/KCXkeZZST+s9dKTfTWcfECNMqN2Zli8ZRlE4Nkmx739 U+h9howdF5m6e1KtYXblmCS1sqW5oAXa/hik5qj9ubdS45FuiCitiT9/KEIvR0SnlORv hfr/HzCztg8mBl44dIGgLbhCucFF/ZwYe8F6GGb19Oe52GG9V9C0VbGnHW9Nq6cLoYdj JYdQ== Received: by 10.66.78.231 with SMTP id e7mr49089944pax.44.1352660832897; Sun, 11 Nov 2012 11:07:12 -0800 (PST) Received: from c-24-19-191-56.hsd1.wa.comcast.net (c-24-19-191-56.hsd1.wa.comcast.net. [24.19.191.56]) by mx.google.com with ESMTPS id a10sm2940083paz.35.2012.11.11.11.07.11 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 11 Nov 2012 11:07:12 -0800 (PST) Date: Sun, 11 Nov 2012 11:07:09 -0800 (PST) From: Garrett Cooper To: linux-rdma@vger.kernel.org Subject: [PATCH] Remove bash'isms/zsh'isms in tcl and shell scripts Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Signed-off-by: Garrett Cooper From 2d35f859094a8a34b2a22100f35dcd1b4148d29e Mon Sep 17 00:00:00 2001 From: Garrett Cooper Date: Mon, 5 Nov 2012 19:43:32 -0800 Subject: [PATCH] Remove bash'isms/zsh'isms in tcl and shell scripts Signed-off-by: Garrett Cooper --- autogen.sh | 4 ++-- ibdiag/autogen.sh | 8 ++++---- ibdm/autogen.sh | 8 ++++---- ibis/autogen.sh | 10 +++++----- ibmgtsim/autogen.sh | 4 ++-- ibmgtsim/tests/OsmTest.check.tcl | 4 ++-- ibmgtsim/tests/osmStress.check.tcl | 2 +- ibmgtsim/tests/pkey.check.tcl | 2 +- ibmgtsim/utils/fprogbar.sh | 32 ++++++++++++++++---------------- ibmgtsim/utils/install.sh | 8 ++++---- ibmgtsim/utils/mkSimNodeDir | 6 +++--- ibmgtsim/utils/uninstall.sh | 15 ++++++--------- 12 files changed, 50 insertions(+), 53 deletions(-) -- 1.7.11.5 diff --git a/autogen.sh b/autogen.sh index dda3137..4b6a990 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh cd ${0%*/*} # get two strings of version numbers # parse the two strings and compare -function compare_versions() { +compare_versions() { cat < /tmp/$$.awk /[0-9]+\.[0-9]+(\.[0-9]+)?[ ]+[0-9]+\.[0-9]+(\.[0-9]+)?/{ vb = "$2"; diff --git a/ibdiag/autogen.sh b/ibdiag/autogen.sh index 642cdc8..fb0f46f 100755 --- a/ibdiag/autogen.sh +++ b/ibdiag/autogen.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh # get two strings of version numbers # parse the two strings and compare -function compare_versions() { +compare_versions() { cat < /tmp/$$.awk /[0-9]+\.[0-9]+(\.[0-9]+)?[ ]+[0-9]+\.[0-9]+(\.[0-9]+)?/{ vb = "$2"; @@ -41,8 +41,8 @@ EOF # We change dir since the later utilities assume to work in the project dir cd ${0%*/*} # remove previous -\rm -rf autom4te.cache -\rm -rf aclocal.m4 +rm -rf autom4te.cache +rm -rf aclocal.m4 # make sure autoconf is up-to-date ac_ver=`autoconf --version | head -n 1 | awk '{print $NF}'` compare_versions 2.59 $ac_ver diff --git a/ibdm/autogen.sh b/ibdm/autogen.sh index 927526f..5eceb89 100755 --- a/ibdm/autogen.sh +++ b/ibdm/autogen.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh # get two strings of version numbers # parse the two strings and compare -function compare_versions() { +compare_versions() { cat < /tmp/$$.awk /[0-9]+\.[0-9]+(\.[0-9]+)?[ ]+[0-9]+\.[0-9]+(\.[0-9]+)?/{ vb = "$2"; @@ -40,8 +40,8 @@ EOF # We change dir since the later utilities assume to work in the project dir cd ${0%*/*} # remove previous -\rm -rf autom4te.cache -\rm -rf aclocal.m4 +rm -rf autom4te.cache +rm -rf aclocal.m4 # make sure autoconf is up-to-date ac_ver=`autoconf --version | head -n 1 | awk '{print $NF}'` compare_versions 2.59 $ac_ver diff --git a/ibis/autogen.sh b/ibis/autogen.sh index c0536a9..6adf391 100755 --- a/ibis/autogen.sh +++ b/ibis/autogen.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh # get two strings of version numbers # parse the two strings and compare -function compare_versions() { +compare_versions() { cat < /tmp/$$.awk /[0-9]+\.[0-9]+(\.[0-9]+)?[ ]+[0-9]+\.[0-9]+(\.[0-9]+)?/{ vb = "$2"; @@ -38,9 +38,9 @@ EOF } cd ${0%*/*} -\rm -rf autom4te.cache -\rm -rf aclocal.m4 -\rm -f config/missing config/install-sh config/depcomp config/mkinstalldirs config/ltmain.sh config/config.sub config/config.guess +rm -rf autom4te.cache +rm -rf aclocal.m4 +rm -f config/missing config/install-sh config/depcomp config/mkinstalldirs config/ltmain.sh config/config.sub config/config.guess # make sure autoconf is up-to-date ac_ver=`autoconf --version | head -n 1 | awk '{print $NF}'` compare_versions 2.59 $ac_ver diff --git a/ibmgtsim/autogen.sh b/ibmgtsim/autogen.sh index a780e64..42c7ed0 100755 --- a/ibmgtsim/autogen.sh +++ b/ibmgtsim/autogen.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh # get two strings of version numbers # parse the two strings and compare -function compare_versions() { +compare_versions() { cat < /tmp/$$.awk /[0-9]+\.[0-9]+(\.[0-9]+)?[ ]+[0-9]+\.[0-9]+(\.[0-9]+)?/{ vb = "$2"; diff --git a/ibmgtsim/tests/OsmTest.check.tcl b/ibmgtsim/tests/OsmTest.check.tcl index 7121d21..ff4c462 100644 --- a/ibmgtsim/tests/OsmTest.check.tcl +++ b/ibmgtsim/tests/OsmTest.check.tcl @@ -49,7 +49,7 @@ proc checker {simDir osmPath osmPortGuid} { set osmTestCmd1 "$osmTestPath -v -t 1000 -g $osmPortGuid -l $osmTestLog -f c -i $osmTestInventory" puts "-I- Invoking: $osmTestCmd1 ..." # HACK: we currently ignore osmtest craches on exit flow: - catch {set res [eval "exec $osmTestCmd1 >& $osmTestStdOutLog"]} + catch {set res [eval "exec $osmTestCmd1 > $osmTestStdOutLog 2>&1"]} if {[catch {exec grep "OSMTEST: TEST \"Create Inventory\" PASS" $osmTestStdOutLog}]} { puts "-E- osmtest Create Inventory failed" @@ -62,7 +62,7 @@ proc checker {simDir osmPath osmPortGuid} { set osmTestCmd2 "$osmTestPath -v -t 1000 -g $osmPortGuid -l $osmTestLog -f a -i $osmTestInventory" puts "-I- Invoking: $osmTestCmd2 ..." # HACK: we currently ignore osmtest craches on exit flow: - catch {set res [eval "exec $osmTestCmd2 >& $osmTestStdOutLog"]} + catch {set res [eval "exec $osmTestCmd2 > $osmTestStdOutLog 2>&1"]} if {[catch {exec grep "OSMTEST: TEST \"All Validations\" PASS" $osmTestStdOutLog}]} { puts "-E- osmtest All Validations failed" return 1 diff --git a/ibmgtsim/tests/osmStress.check.tcl b/ibmgtsim/tests/osmStress.check.tcl index 2c741cb..f6e9d75 100755 --- a/ibmgtsim/tests/osmStress.check.tcl +++ b/ibmgtsim/tests/osmStress.check.tcl @@ -205,7 +205,7 @@ proc checker {simDir osmPath osmPortGuid} { set cmd "ibdiagnet -v -r -t $topologyFile -o $simDir" set ibdiagnetLog [file join $simDir ibdiagnet.stdout.log] puts "-I- Invoking $cmd " - if {[catch {set res [eval "exec $cmd >& $ibdiagnetLog"]} e]} { + if {[catch {set res [eval "exec $cmd > $ibdiagnetLog 2>&1"]} e]} { puts "-E- ibdiagnet failed" puts "-I- Result value $res" puts "-I- Error: $e" diff --git a/ibmgtsim/tests/pkey.check.tcl b/ibmgtsim/tests/pkey.check.tcl index 7083808..ecfdbee 100644 --- a/ibmgtsim/tests/pkey.check.tcl +++ b/ibmgtsim/tests/pkey.check.tcl @@ -310,7 +310,7 @@ proc checker {simDir osmPath osmPortGuid} { puts "-I- Invoking: $osmTestCmd1 ..." # HACK: we currently ignore osmtest craches on exit flow: - catch {set res [eval "exec $osmTestCmd1 >& $osmTestStdOutLog"]} + catch {set res [eval "exec $osmTestCmd1 > $osmTestStdOutLog 2>&1"]} if {[catch {exec grep "OSMTEST: TEST \"Create Inventory\" PASS" $osmTestStdOutLog}]} { puts "-E- osmtest Create Inventory failed" diff --git a/ibmgtsim/utils/fprogbar.sh b/ibmgtsim/utils/fprogbar.sh index 7805ff0..0a5f28c 100755 --- a/ibmgtsim/utils/fprogbar.sh +++ b/ibmgtsim/utils/fprogbar.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # fprogbar: File PROGress BAR # This script output a progress bar in the terminal width which monitors # file size relative to final expected size. @@ -10,7 +10,7 @@ # Note: It is recommended to provide final size which is a bit less than # expected size, since this size is the termination point -function usage() +usage() { echo "usage: fprogbar []" exit 1 @@ -32,29 +32,29 @@ fi # prepare progress bar of style [ ] to be [+++ ] echo -n "[]" -let num_of_dots=`tput cols`-12 -#for (( i= 0 ; i < $num_of_dots ; )) ; do echo -n -e '\267' ; let i++ ;done +num_of_dots=`tput cols`-12 +#i=0; while [ $i -lt $num_of_dots ] ; do echo -n -e '\267' ; : $(( i += 1 )); done #echo -n -e \]'\r'\[ -let bytes_per_dot=$final_sz/$num_of_dots -let cur_bars=0 -let percent=0 +bytes_per_dot=$(( $final_sz / $num_of_dots )) +cur_bars=0 +percent=0 # Update dots until final size is reached -while ((1)); do - lead_proc_cnt=`ps -eo "%p" | awk '$1 == '$pid2track' {print}' | wc -l` +while : ; do + lead_proc_cnt=`ps -eo "%p" | awk '$1 == '$pid2track | wc -l` current_sz=`ls -l $file | awk '{print $5}'` - let req_bars=$current_sz/$bytes_per_dot + req_bars=$(( $current_sz / $bytes_per_dot )) if [ $req_bars -ge $num_of_dots ]; then - let req_bars=$num_of_dots + req_bars=$num_of_dots fi - for (( ; $cur_bars < $req_bars ; )); do - let percent=($current_sz*100)/$final_sz + while [ $cur_bars -lt $req_bars ]; do + percent=$(( $(( $current_sz * 100 )) / $final_sz )) printf "\b+] %3d%%\b\b\b\b\b" $percent - let cur_bars++ + : $(( cur_bars += 1 )) done # Check if reached expected file size - if [ \( $cur_bars -eq $num_of_dots \) -o \( $percent -ge 100 \) ]; then + if [ $cur_bars -eq $num_of_dots -o $percent -ge 100 ]; then echo " 100%" exit 0 fi @@ -65,5 +65,5 @@ while ((1)); do exit 2 fi - usleep 200000 + sleep 0.2 done diff --git a/ibmgtsim/utils/install.sh b/ibmgtsim/utils/install.sh index 1d892d5..e0a0958 100755 --- a/ibmgtsim/utils/install.sh +++ b/ibmgtsim/utils/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # This software is available to you under a choice of one of two # licenses. You may choose to be licensed under the terms of the GNU @@ -41,13 +41,13 @@ cd $PACKAGE_DIR # #Report: if config failed -function config_failed() { +config_failed() { echo "Config failed ! (see $CFGLOG for details)" exit 1 } #Report: if make failed -function make_failed() { +make_failed() { echo "Make failed ! (see $MAKELOG for details)" exit 1 } @@ -59,7 +59,7 @@ PREFIX=/usr NO_BAR=0 # parse parameters -while [ "$1" ]; do +while [ $# -gt 0 ]; do # echo "Current parsed param is : $1" case $1 in "--prefix") diff --git a/ibmgtsim/utils/mkSimNodeDir b/ibmgtsim/utils/mkSimNodeDir index dcab4b3..d7322df 100755 --- a/ibmgtsim/utils/mkSimNodeDir +++ b/ibmgtsim/utils/mkSimNodeDir @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/sh usage="$0 -n node-name [-g sim-guids-file]" -function help () { +help() { cat <1 > /dev/null; - if [ $? == 0 ]; then + if rm -f ${PREFIX}/bin/$f 2>&1 >/dev/null; then echo " Removed : ${PREFIX}/bin/$f" fi done echo "Removing Include Files from : ........ $PREFIX/include." - rm -rf ${PREFIX}/include/ibmgtsim 2&>1 > /dev/null - if [ $? == 0 ]; then + if rm -rf ${PREFIX}/include/ibmgtsim 2>&1 >/dev/null; then echo " Removed : ${PREFIX}/include/ibmgtsim" fi @@ -42,8 +40,7 @@ function cleanup_ibmgtsim_files() { libs="libibmscli.a libibmscli.la libibmscli.so libibmscli.so.1 libibmscli.so.1.0.0" for f in $libs; do - rm -rf ${PREFIX}/lib/$f 2&>1 > /dev/null; - if [ $? == 0 ]; then + if rm -rf ${PREFIX}/lib/$f 2>&1 >/dev/null; then echo " Removed : ${PREFIX}/lib/$f" fi done @@ -52,7 +49,7 @@ function cleanup_ibmgtsim_files() { NO_BAR=0 # parse parameters -while [ "$1" ]; do +while [ $# -gt 0 ]; do # echo "Current parsed param is : $1" case $1 in "--prefix")