problem with type argument parsing

9 views
Skip to first unread message

cd...@mutable.host

unread,
Dec 13, 2020, 3:13:04 AM12/13/20
to cdist-configura...@googlegroups.com
Hi,

I am coming across a problem with argument parsing, I am not sure if it is me missing something or if it is a bug. I would value your comments.


The attached __broken type illustrates this.


$ cdist config -v localhost -i - <<EOF
__broken /tmp/test --arg '-n' --arg '-e'
EOF
INFO: localhost: Starting configuration run
ERROR: localhost: /bin/sh -e /tmp/cdist.stdin.02i9h1cy: ['/bin/sh', '-e', '/tmp/cdist.stdin.02i9h1cy']

Error processing initial manifest
=================================
path: /tmp/cdist.stdin.02i9h1cy

init:stderr
-----------
usage: __broken [--arg ARG] object_id
__broken: error: argument --arg: expected one argument


ERROR: cdist: Failed to configure the following hosts: localhost
$

Thanks.
__broken.tar

Mark Verboom

unread,
Dec 13, 2020, 3:51:22 AM12/13/20
to cdist-configura...@googlegroups.com
Hi,

Not sure, but does it help to escape the - passed to the arg? So --arg '\-n'?

Regards,

Mark
> --
> You received this message because you are subscribed to the Google Groups "cdist-configuration-management" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cdist-configuration-m...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cdist-configuration-management/20201213081245.GA498480%40esilver.



--
"I know you think you understand what you thought I said but I'm not sure you
realize that what you heard is not what I meant."

cd...@mutable.host

unread,
Dec 13, 2020, 5:07:58 AM12/13/20
to cdist-configura...@googlegroups.com, Mark Verboom
Thanks for your reply,

Unfortunately no joy.
'\-n' and "-n" don't seem to work.
On the other hand, a more complex argument does work:
--arg '-e "s/bob/smith/g"'

I don't know cdist internals, so wouldn't know where to begin debugging.

Thanks.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cdist-configuration-management/20201213085113.GG808%40shell.lnw.verboom.net.

Nico Schottelius

unread,
Dec 13, 2020, 5:21:51 AM12/13/20
to cd...@mutable.host, Mark Verboom, cdist-configura...@googlegroups.com

Good morning,

the "parsing" question is very simple: we're using plain pythor
argparse:

https://docs.python.org/3/library/argparse.html

Shell wise, -n and '-n' are the same thing when being seen by the
program. What you are probably looking for is "--", but that stops
processing parameters.

Note: the problem is not with cdist, but a logical one ("when is -x
an argument, when a parameter"?)

Cheers,

Nico

(*) Anything that is a bit of a reduced set in terms of o
--
Modern, affordable, Swiss Virtual Machines. Visit www.datacenterlight.ch
Reply all
Reply to author
Forward
0 new messages