Re: using bash features in init scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



also you would wanna add requires: bash for initscripts rpm.

not sure how portable initscripts package was designed to be, would anyone
ever use it outside redhat? if not making a commitment to bash could be
reasonable.

just my .02
v

On Sun, 28 Sep 2003, Jonathan Bartlett wrote:

> The reason that normal startup scripts don't, is that there's no guarantee
> /bin/sh will point to bash, or even that bash is installed.
> 
> If you want to use bash, the first line should be /bin/bash instead of
> /bin/sh, so it's obvious it needs bash specifically.
> 
> Jon
> 
> On Sun, 28 Sep 2003, [iso-8859-1] Manoj Kumar wrote:
> 
> > Is there any reason not to use bash features in init
> > scripts?
> > Consider, for example, this fragment from
> > /etc/sysconfig/network-scripts/ifup-post:
> >
> >     DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
> >     REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
> >     if echo $DEVICE | grep -q ':' ; then
> >         ISALIAS=yes
> >     else
> >         ISALIAS=no
> >     fi
> >
> > In bash we can do this much faster with something like
> > this:
> >
> >     DEVICETYPE=$DEVICE
> >     while [[ $DEVICETYPE == *[0-9] ]]; do
> >         DEVICETYPE=${DEVICETYPE%[0-9]}
> >     done
> >     REALDEVICE=${DEVICE%%:*}
> >     if [[ $DEVICE == *:* ]]; then
> >         ISALIAS=yes
> >     else
> >         ISALIAS=no
> >     fi
> >
> > Okay, the loop that replaces the first line is messy,
> > but it saves
> > a couple of forks and an exec.  The other two changes
> > are both
> > simpler and faster.
> >
> > So why do most init scripts use sed and grep to
> > process
> > strings?  It can't be a desire to allow them to work
> > with the
> > Bourne shell (why would we want that anyway?) because
> > some
> > scripts do use bash features.
> >
> > manojkumar_137@xxxxxxxxxxx
> >
> >
> > ________________________________________________________________________
> > Yahoo! India Matrimony: Find your partner online.
> > Go to http://yahoo.shaadi.com
> >
> >
> > _______________________________________________
> > Redhat-devel-list mailing list
> > Redhat-devel-list@xxxxxxxxxx
> > https://www.redhat.com/mailman/listinfo/redhat-devel-list
> >
> 
> 
> _______________________________________________
> Redhat-devel-list mailing list
> Redhat-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/redhat-devel-list
> 


_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux