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

Quotes not recognized in baseCommand #9

Open
drjrm3 opened this issue Jun 14, 2018 · 5 comments
Open

Quotes not recognized in baseCommand #9

drjrm3 opened this issue Jun 14, 2018 · 5 comments
Labels

Comments

@drjrm3
Copy link

drjrm3 commented Jun 14, 2018

We have a simple workflow which uses baseCommand: [awk, '{print $2}'] and the interpreted command does not keep the ''s. Instead, it interprets the baseCommand as "baseCommand" : [ "awk", "{print $2}" ], (line 40 in the attached outfile.txt) and attempts to execute awk {print $2} (line 148) which fails.
BaseCommandError.tar.gz

@liuboxa
Copy link
Collaborator

liuboxa commented Jun 19, 2018

As a workaround, you can use double quotes (") to quote the command in baseCommand, e.g. baseCommand: ["awk", "'{print $2}'"]

In deed, this is a bug, we will fix it finally

@drkennetz
Copy link

Thanks for the response, this has been my workaround for the above example. However, if the awk command contains quotes itself:
baseCommand: [awk, "'{$5=$6=$7=$8=""; print $0}'"]
cwltool fails causing cwlexec to not even start the job (because the input failed validation).
Syntax error while parsing a flow sequence File:///awkColumnDisplace.cwl", line 22, column 14 expected ',' or ']', but got '<scalar>'

@liuboxa
Copy link
Collaborator

liuboxa commented Jun 25, 2018

@drkennetz and @drjrm3
cwlexec use jackson to parse the cwl definition/inputs files, but jackson doesn't seem to work very well when a field has the single quotes ('), so we suggest you use double quotes (") to quote the command options

FasterXML/jackson-core#235
json-path/JsonPath#275

@drkennetz
For your case, you should escape the double quotes (") in your string, e.g.
baseCommand: [awk, "'{$5=$6=$7=$8=\"\"; print $0}'"]
This will work well

@biokcb
Copy link

biokcb commented Jul 6, 2018

Hello,

I am having a related issue, where having an input as a string type builds the command incorrectly. I have attached a simple case where there are 3 input examples given. The first two cause an error with my shell script because it expects only two fields.

message: hello world
Expected out_1.txt: hello world
Actual out_1.txt: Errors out because the input needs quotes

message: "hello world"
Expected out_2.txt: hello world
Actual out_2.txt: Errors out because the input needs quotes and cwlexec gets rid of them

message: "'hello world'"
Expected out_3.txt: 'hello world'
Actual out_3.txt: hello world

So the workaround given does get around the quotes issue and it will work, but the output is different than the expected output which causes reproducibility issues if I want to use the script with cwlexec and cwltool. Thanks!

StringQuotesError.tar.gz

@skeeey
Copy link
Collaborator

skeeey commented Jul 13, 2018

@biokcb
Thanks for your cases, they are good cases for us, the quotes problem is more trick :( , but I think you may follow below rules:

message: hello world

equals

message: "hello world"

and equals

message: 'hello world'

all of above definitions will get a string that does not has any quotes (hello world)

If you want to define a string that has double quotes ("hello world"), you need define it to

message: '"hello world"'

or

message: "\"hello world\""

and if you want to define a string that has single quotes ('hello world'), you need define it to

message: "'hello world'"

@skeeey skeeey added FAQ and removed workaround labels Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants