On Wed, Aug 13, 2008 at 09:29:47AM +1000, Simon Horman wrote:
> On Wed, Aug 06, 2008 at 10:32:21PM +0200, Dejan Muhamedagic wrote:
> > Hi David,
> >
> > On Wed, Aug 06, 2008 at 02:42:10PM +0100, David Lee wrote:
> > > On Wed, 6 Aug 2008, Simon Horman wrote:
> > >
> > > > In some environments, such as dash, $RANDOM is empty.
> > > > This fixes up the last two references that I could find
> > > > in the tree to $RANDOM to make sure they are sensible in
> > > > this case.
> > >
> > > (Disclaimer: my mind is even less focussed than usual, having had a week's
> > > sick-leave...)
> > >
> > > Sounds OK in principle. But a detail:
> > >
> > > > --- heartbeat.orig/resources/OCF/.ocf-shellfuncs.in 2008-08-06
> > > > 20:05:13.000000000 +1000
> > > > +++ heartbeat/resources/OCF/.ocf-shellfuncs.in 2008-08-06
> > > > 20:05:23.000000000 +1000
> > > > @@ -58,6 +58,13 @@ ocf_is_root() {
> > > > esac
> > > > }
> > > >
> > > > +ocf_maybe_random() {
> > > > + local rnd="$RANDOM"
> > > > [...]
> > >
> > > That "local ..." construction: is that a true Bourne feature? In this
> > > "shellfuncs" area, we need to be as portable as possible, avoiding
> > > "bash-isms". (I think we accept that some particular OCFs could well be
> > > "bash" these days, but these utility functions, shared across all OCFs,
> > > need to be Bourne.)
> > >
> > >
> > > > [...]
> > > > ocf_take_lock() {
> > > > - lockfile=$1
> > > > -
> > > > - if [ ! -n $RANDOM ]; then
> > > > - # Something sane-ish in case a shell doesn't support $RANDOM
> > > > - RANDOM=$$
> > > > - fi
> > > > + local lockfile=$1
> > > > + local rnd=$(ocf_maybe_random)
> > > > [...]
> > >
> > > ... that "local ..." again.
> > >
> > > Hope that helps.
> >
> > The "local" keyword is I think in the POSIX standard. Is there a
> > platform with shell which doesn't comply with the POSIX at least?
>
> Yes, I believe local is POSIX, though I used it in a bashish way :-(
>
> It should be
>
> local blah
> blah=foo
>
> not
>
> local blah=foo
>
> I will fix this shortly.
Sorry, I've poked around a bit further and I no longer think that
local is POSIX.
http://marc.info/?l=linux-ha-dev&m=121858676924998&w=2
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/