Skip to contentSkip to conversation

Use bash

PATCH New Zdenek Kabelac 2 participants 6 messages May 14, 2010

lore
Share & tools
lore
#0 lore raw

cover Use bash

Zdenek Kabelac (1):
Use /bin/bash instead of /bin/sh

 scripts/clvmd_fix_conf.sh       |    2 +-
 scripts/fsadm.sh                |    2 +-
 scripts/last_cvs_update.sh      |    2 +-
 scripts/lvmconf.sh              |    2 +-
 scripts/lvmconf_lockingtype2.sh |    2 +-
 scripts/vgimportclone.sh        |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
#1 lore raw

PATCH 1/1 Use /bin/bash instead of /bin/sh

Use /bin/bash for scripts using bashisms.
For all of them 'checkbashisms' command reports miscelanous things available only in nonstandard shell extensions like bash.

For more details check i.e.: https://wiki.ubuntu.com/DashAsBinSh

---
 scripts/clvmd_fix_conf.sh       |    2 +-
 scripts/fsadm.sh                |    2 +-
 scripts/last_cvs_update.sh      |    2 +-
 scripts/lvmconf.sh              |    2 +-
 scripts/lvmconf_lockingtype2.sh |    2 +-
 scripts/vgimportclone.sh        |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
scripts/clvmd_fix_conf.sh +1 -1
index a00263c..cc2c50d 100644
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Edit an lvm.conf file to enable cluster locking.
 #
scripts/fsadm.sh +1 -1
index 13b48a0..90a93ee 100644
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
 #
scripts/last_cvs_update.sh +1 -1
index e38d0ec..7b5afea 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #$Header$
 ################################################################################
 ##
scripts/lvmconf.sh +1 -1
index bf1494b..3caaf91 100644
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
 #
scripts/lvmconf_lockingtype2.sh +1 -1
index f5c4313..b823a43 100644
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
 #
scripts/vgimportclone.sh +1 -1
index ecf0546..731b860 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Copyright (C) 2009 Chris Procter All rights reserved.
 # Copyright (C) 2009 Red Hat, Inc. All rights reserved.
Signature · 1 line
1.7.0.1
#2 lore raw

PATCH 1/1 Use /bin/bash instead of /bin/sh

Quoted 3 lines · Zdenek Kabelac

Use /bin/bash for scripts using bashisms.
For all of them 'checkbashisms' command reports miscelanous things available only in nonstandard shell extensions like bash.

Please post the output so we can see.

Alasdair

#3 lore raw

PATCH 1/1 Use /bin/bash instead of /bin/sh

Dne 14.5.2010 12:40, Alasdair G Kergon napsal(a):

Quoted 7 lines · Zdenek Kabelac
Quoted 3 lines

Use /bin/bash for scripts using bashisms.
For all of them 'checkbashisms' command reports miscelanous things available only in nonstandard shell extensions like bash.

Please post the output so we can see.

Some of them could be easily fixed - some of them are trickier (i.e. ${RANDOM}) - as we already use bash for other scripts anyway - I've considered it's fairly easier to use bash for these as well...

Zdenek

------------------

scripts/clvmd_fix_conf.sh
possible bashism in scripts/clvmd_fix_conf.sh line 35 (${foo:3[:1]}):
if [ "${PREFIX:0:1}" != "/" ]
possible bashism in scripts/clvmd_fix_conf.sh line 135 (echo -e):
echo -e $SEDCMD > $SCRIPTFILE
------------------
scripts/fsadm.sh
possible bashism in scripts/fsadm.sh line 63 ($RANDOM):
TEMPDIR="${TMPDIR:-/tmp}/${TOOL}_${RANDOM}$$/m"
possible bashism in scripts/fsadm.sh line 119 (trap with signal numbers):

	trap '' 2

------------------
scripts/last_cvs_update.sh
possible bashism in scripts/last_cvs_update.sh line 36 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ -z $1 ]];
possible bashism in scripts/last_cvs_update.sh line 39 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ $1 == "-h" ]];
possible bashism in scripts/last_cvs_update.sh line 39 (should be 'b = a'):
if [[ $1 == "-h" ]];
possible bashism in scripts/last_cvs_update.sh line 43 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ -d $1 ]]
possible bashism in scripts/last_cvs_update.sh line 53 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ -f $path/CVS/Tag ]];
------------------
scripts/lvmconf.sh
possible bashism in scripts/lvmconf.sh line 19 ('function' is useless):
function usage
possible bashism in scripts/lvmconf.sh line 34 ('function' is useless):
function parse_args
possible bashism in scripts/lvmconf.sh line 80 ('function' is useless):
function validate_args
possible bashism in scripts/lvmconf.sh line 97 (${foo:3[:1]}):

        if [ "${LOCKINGLIBDIR:0:1}" != "/" ]

possible bashism in scripts/lvmconf.sh line 236 (echo -e):
echo -e $SEDCMD > $SCRIPTFILE
------------------
scripts/lvmconf_lockingtype2.sh
possible bashism in scripts/lvmconf_lockingtype2.sh line 19 ('function' is useless):
function usage
possible bashism in scripts/lvmconf_lockingtype2.sh line 34 ('function' is useless):
function parse_args
possible bashism in scripts/lvmconf_lockingtype2.sh line 80 ('function' is useless):
function validate_args
possible bashism in scripts/lvmconf_lockingtype2.sh line 99 (${foo:3[:1]}):

        if [ "${LOCKINGLIBDIR:0:1}" != "/" ]

possible bashism in scripts/lvmconf_lockingtype2.sh line 233 (echo -e):
echo -e $SEDCMD > $SCRIPTFILE
------------------
scripts/vgimportclone.sh
possible bashism in scripts/vgimportclone.sh line 40 (should be >word 2>&1):
"$LVM" version >& /dev/null || die 2 "Could not run lvm binary '$LVM'" possible bashism in scripts/vgimportclone.sh line 43 ('function' is useless):
function getvgname {
possible bashism in scripts/vgimportclone.sh line 55 (alternative test command ([[ foo ]] should be [ foo ])):

    while [[ "${VGLIST}" =~ "${NAME}" ]]

possible bashism in scripts/vgimportclone.sh line 64 ('function' is useless):
function checkvalue {
possible bashism in scripts/vgimportclone.sh line 73 ('function' is useless):
function usage {
possible bashism in scripts/vgimportclone.sh line 89 ('function' is useless):
function cleanup {
possible bashism in scripts/vgimportclone.sh line 103 ($UID should be "$(id -ru)"):
if [ "$UID" != "0" -a "$EUID" != "0" ]
possible bashism in scripts/vgimportclone.sh line 103 ($EUID should be "$(id -u)"):
if [ "$UID" != "0" -a "$EUID" != "0" ]
possible bashism in scripts/vgimportclone.sh line 125 (trap with signal numbers):
trap cleanup 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 possible bashism in scripts/vgimportclone.sh line 154 (let ...):
let VERBOSE_COUNT=VERBOSE_COUNT+1
possible bashism in scripts/vgimportclone.sh line 320 (alternative test command ([[ foo ]] should be [ foo ])):

    if [[ "${PVLIST}" =~ "unknown" ]]

------------------

#4 lore raw

PATCH 1/1 Use /bin/bash instead of /bin/sh

Quoted 3 lines · Zdenek Kabelac

Some of them could be easily fixed - some of them are trickier (i.e. ${RANDOM}) - as we already use bash for other scripts anyway - I've considered it's fairly easier to use bash for these as well...

Well it's fine to use some of those helpful bash extensions - pretty much every system has it available these days - but we should still clean up the ones here where the original syntax is equally good.

Alasdair