Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options are not passed correctly to programs #201

Closed

Conversation

gschueler
Copy link
Member

Using a simple bash script as follows:

#!/bin/bash
echo "Here's the list of command line options:"

for i in "$@"; do
  echo "** $i **"
done

I have defined an option (named "option1") with no default value and no restrictions, so the user can enter any value.
In the job definition, I invoke the command

/path/to/testprog.sh ${option.option1}

If the value entered by the user does not start with a dash, the program receives it correctly; if it starts with a dash, the programs receives the string "true". This looks like a pretty serious bug to me, unless I'm misunderstanding something (which of course is possible).

I'm also having trouble running the same job from the command line, I'll open a separate issue for that.

@satyagraha
Copy link

I confirm the problem with leading - values, which is easy to reproduce as above. I was trying to pass Java system properties via a -Dkey=val and got the "true" value. If you pass in this string with a leading space it does get through, and is enclosed in single quotes when substituted.

@gschueler
Copy link
Member

I think I understand the problem now, you are saying that if an option value is something like "-value", the value will not be used correctly when passed to the underlying script execution.

My guess is the options parser is incorrectly treating "-optionname -value" as if it were two separate boolean flag options. However, rundeck doesn't (any longer) allow that kind of option, so it must have some lingering improper treatment of the options string.

John Burbridge and others added 28 commits January 15, 2013 10:01
…nCentral

Merge branch 'issues/276-illegal-gradle-dependencies' of git.soma.salesforce.com:gigantor/rundeck into issues/276-illegal-gradle-dependencies
This is the (very) beginning of a fix to rundeck#298.

Unfortunately, doing this in a way that doesn't compromise backwards
compatibility is out-of-scope, and will probably call for a multi-phase
implementation -- for instance, adding a per-job flag to specify
compatible or safe quoting, providing warnings and (eventually)
deprecation notices to users with jobs using unsafe quoting, and (again,
eventually) flipping the default.
Shell quoting does not apply to entire argv elements, but only
individual characters thereof -- and different characters within a
string can be quoted in different ways. As such, a promise to treat
"pre-quoted" argv elements differently is not sensible; moreover, this
promise restricts the set of data which can be legitimately passed
(whereas natively, argv array entries can contain any non-NUL bytes --
including, of course, embedded literal quotes).

The new, safe algorithm does not respect the traditional
implementation's promise to preserve original quoting. Clarify this in
the docstring.
…esforce.com:gigantor/rundeck into issues/276-illegal-gradle-dependencies
…gradle-dependencies

Changes to repos / dependency management

Conflicts:
	rundeckapp/build.gradle
Add alternate, safe quoting to CLIUtils (optional, off-by-default)
…e-dependencies

Remove gradle runtime dependencies hack.

Conflicts:
	core/pom.xml
Docs are built separately as a zip

war no longer includes docs within it
@ghost ghost assigned gschueler Apr 23, 2013
Remove old boolean value support for "-flag", and clean up
javadoc and parsing.
@buildhive
Copy link

DTO Labs » rundeck #47 SUCCESS
This pull request looks good
(what's this?)

gschueler added a commit that referenced this pull request Apr 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants