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.
--
: David Lee I.T. Service :
: Senior Systems Programmer Computer Centre :
: UNIX Team Leader Durham University :
: South Road :
: http://www.dur.ac.uk/t.d.lee/ Durham DH1 3LE :
: Phone: +44 191 334 2752 U.K. :
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/