[ClusterLabs] ocf scripts shell and local variables

Dejan Muhamedagic dejanmm at fastmail.fm
Mon Aug 29 10:37:00 EDT 2016


Hi,

On Mon, Aug 29, 2016 at 02:58:11PM +0200, Gabriele Bulfon wrote:
> I think the main issue is the usage of the "local" operator in ocf*
> I'm not an expert on this operator (never used!), don't know how hard it is to replace it with a standard version.

Unfortunately, there's no command defined in POSIX which serves
the purpose of local, i.e. setting variables' scope. "local" is,
however, supported in almost all shells (including most versions
of ksh, but apparently not the one you run) and hence we
tolerated that in /bin/sh resource agents.

Thanks,

Dejan

> Happy to contribute, it still the case
> Gabriele
> ----------------------------------------------------------------------------------------
> Sonicle S.r.l.
> :
> http://www.sonicle.com
> Music:
> http://www.gabrielebulfon.com
> Quantum Mechanics :
> http://www.cdbaby.com/cd/gabrielebulfon
> ----------------------------------------------------------------------------------
> Da: Kristoffer Gr?nlund
> A: gbulfon at sonicle.com Cluster Labs - All topics related to open-source clustering welcomed
> kgaillot at redhat.com Cluster Labs - All topics related to open-source clustering welcomed
> Data: 29 agosto 2016 14.36.23 CEST
> Oggetto: Re: [ClusterLabs] ocf scripts shell and local variables
> Gabriele Bulfon
> writes:
> Hi Ken,
> I have been talking with the illumos guys about the shell problem.
> They all agreed that ksh (and specially the ksh93 used in illumos) is absolutely Bourne-compatible, and that the "local" variables used in the ocf shells is not a Bourne syntax, but probably a bash specific.
> This means that pointing the scripts to "#!/bin/sh" is portable as long as the scripts are really Bourne-shell only syntax, as any Unix variant may link whatever Bourne-shell they like.
> In this case, it should point to "#!/bin/bash" or whatever shell the script was written for.
> Also, in this case, the starting point is not the ocf-* script, but the original RA (IPaddr, but almost all of them).
> What about making the code base of RA and ocf-* portable?
> It may be just by changing them to point to bash, or with some kind of configure modifier to be able to specify the shell to use.
> Meanwhile, changing the scripts by hands into #!/bin/bash worked like a charm, and I will start patching.
> Gabriele
> Hi Gabriele,
> Yes, your observation is correct: The resource scripts are not fully
> POSIX compatible in this respect. We have been fixing these issues as
> they come up, but since we all use bash-like shells it has never become
> a pressing issue (IIRC Debian did have some of the same issues since
> /bin/sh there is dash, which is also not fully bash-compatible).
> It would be fantastic if you could file issues or submit patches at
> https://github.com/ClusterLabs/resource-agents for the resource agents
> where you still find these problems.
> Cheers,
> Kristoffer
> --
> // Kristoffer Gr?nlund
> // kgronlund at suse.com

> _______________________________________________
> Users mailing list: Users at clusterlabs.org
> http://clusterlabs.org/mailman/listinfo/users
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org





More information about the Users mailing list