Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Quotes make a difference in 2.1.16

7 views
Skip to first unread message

Chip Seraphine

unread,
Oct 12, 2005, 2:09:56 PM10/12/05
to Cfengine Mailing List Help <help-cfengine@gnu.org> >> Cfengine Mailing List Help
Not sure if this is a bug or a feature, but in the newly-patch version
of cfengine 2.1.16 (2.1.16p1?):

control:
pf_cc= "/usr/bin/gcc"
pf_cc_vers= (
ExecResult(/bin/sh -c "${pf_cc} --version | head -1 | cut -d\
-f3")
)


...used to produce the version number of /usr/bin/gcc, but now running
this command produces "/usr/bin/gcc: no input files".

Running under debug shows:
RecordMacroId(pf_cc_vers)
HandleFunctionObject(ExecResult(/bin/sh -c "${pf_cc} --version | head -1
| cut -d\ -f3"))
IsBuiltinFunction(ExecResult(/bin/sh -c "${pf_cc} --version | head -1 |
cut -d\ -f3"))
IsBuiltinFunction: ExecResult(/bin/sh -c "${pf_cc} --version | head -1 |
cut -d\ -f3")
HandleFunction: ExecResult(/bin/sh -c "${pf_cc} --version | head -1 |
cut -d\ -f3")
FunctionStringToCode(ExecResult)
Appending [/bin/sh -c ${pf_cc} --version | head -1 | cut -d\ -f3]
ExpandVarstring(/bin/sh -c ${pf_cc} --version | head -1 | cut -d\ -f3)
Returning substring value pf_cc
Scanning variable pf_cc
GetMacroValue(main,pf_cc)
Expansion gave (/bin/sh -c /usr/bin/gcc)
ARG[0] /bin/sh -c /usr/bin/gcc --version | head -1 | cut -d\ -f3
cfpopen(/bin/sh -c /usr/bin/gcc --version | head -1 | cut -d\ -f3)
GetExecOutput got: [gcc: no input files]
cfpclose(pp)


The "Expansion gave...." line shows what is actually being executed,
namely gcc with no arguments.

Changing the double quotes to singlequotes in the ExecResult seems to
make cfengine happy, as does rolling back to 2.1.15. In other words,
changing the above snippet to:

control:
pf_cc= "/usr/bin/gcc"
pf_cc_vers= (
ExecResult(/bin/sh -c '${pf_cc} --version | head -1 | cut -d\
-f3')
)


...produces the same results in 2.1.15 as 2.1.16.


Paul Krizak

unread,
Oct 12, 2005, 2:19:38 PM10/12/05
to Chip Seraphine, Cfengine Mailing List Help <help-cfengine@gnu.org> >> Cfengine Mailing List Help
We've always just avoided problems with quotes by using $(dblquote)
instead of ".

Paul Krizak 5900 E. Ben White Blvd. MS 625
Advanced Micro Devies Austin, Tx 78741
CAD Systems Engineering Phone: (512) 602-8775
Paul....@amd.com

> _______________________________________________
> Help-cfengine mailing list
> Help-c...@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine

0 new messages