On Wed, Sep 22, 2010 at 08:26:43AM -0600, Serge Dubrouski wrote: > Thanks, Dejan - > > There was one more little patch for pgsql to replace: > > ocf_run $quietrun su $OCF_RESKEY_pgdba -c "$*" > > with > > ocf_run $quietrun su $OCF_RESKEY_pgdba -c "cd $OCF_RESKEY_pgdata; $@"
Don't do that. shell quoting is like gamling at times. o() { output=`"$@" 2>&1`; set +x; echo "----- result:"; echo "$output"; }; p0() { ( set -x; o su lars -c "cd . ; $@" ); } p1() { ( set -x; o su lars -c "cd . ; $*" ); } # invokation: The "$@" Variant: # p0 'printf "%s\n"' "a white space a" b c d + o su lars -c 'cd . ; printf "%s\n"' 'a white space a' b c d ++ su lars -c 'cd . ; printf "%s\n"' 'a white space a' b c d + output= + set +x ----- result: D'oh. Nothing. Why? Because the extra arguments have become extra arguments to su as well, and are no longer part of the script passed to -c. The "$*" Variant: # p1 'printf "%s\n"' "a white space a" b c d + o su lars -c 'cd . ; printf "%s\n" a white space a b c d' ++ su lars -c 'cd . ; printf "%s\n" a white space a b c d' + output='a white space a b c d' + set +x ----- result: a white space a b c d Not too good, but at least acceptable. All in one parameter, special case, no difference with $* and $@ # p1 'printf "%s\n" "a white space a" b c d' + o su lars -c 'cd . ; printf "%s\n" "a white space a" b c d' ++ su lars -c 'cd . ; printf "%s\n" "a white space a" b c d' + output='a white space a b c d' + set +x ----- result: a white space a b c d It does not make a difference for the current use of runasowner, as long as you use it always with exactly one parameter. But as that is non-obvious to most, and people are going to copy'n'paste from that resource agent later, don't do the "$@". Expansion of $@ and $* within double quotes is very much different, and $@ in this context is very likely wrong, as it may pass flags to su which had been meant to be passed to the command run within -c. But yes, do the "cd $OCF_RESKEY_pgdata; $*". No problem with that. -- : Lars Ellenberg : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. _______________________________________________________ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/