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
Command Line Modules not handling empty strings correctly when passing to back end. #307
Comments
Shouldn't the following be passed ?
I can't think of an issue right now, but I think there might be some danger to consider "argument not being passed' and "empty argument" to be the same. |
My original intention was to stop command line modules crashing when the parameter flag was passed, and the command line module then expected a value that was not passed. The SlicerExecutionModel project generates a command line parser that either expects an argument not to be passed, or it to be passed along with its value. So, while I can see your point, this code change seems to be correct in terms of what the underlying command line module expects. |
I'm sure your fix works fine with SlicerExecutionModel.
or b)
I would vote for a) as it is more verbose and more explicit. |
Sure. I don't know. I will await Sascha's opinion as it currently affects MITK users and NifTK users. I would vote for merging this change, as the current implementation just crashes. Im happy to take any advice though. |
Agree with Julien. If an empty string is valid, you could set the parameter as optional with Jc Sent from my mobile device
|
@MattClarkson Thanks for working on this one! I actually also would prefer option a) . I think we should just pass all parameters to the command line module. While we could omit the arguments where the user did not change the default value, I don't see much value in it. Talking about empty arguments, I think we should also just always quote all passed arguments, in case there are spaces or special characters. |
For issue #307, as user may have explicitly removed the default.
For issue #307, as user may have explicitly removed the default.
I agree with Sascha, all the arguments should probably be quoted. |
OK. Thanks for feedback. The original problem was strings not being passed to back end at all. This was fixed in #306. Then there was the fact that empty strings were not passed, which was the original intention of #307. This was raised as a separate issue, as once #306 was fixed, it was realised that empty strings caused this: --myParameter1 --myParameter2 Banana so after Juliens (and others) suggestions, it now passes: --myParameter1 "" --myParameter2 Banana In my case, I don't actually have command line modules that pass strings, so I admit my testing was a little too narrow. The current solution is now better than it was before #306 and #307. However, I have had numerous problems with trying to get strings with quotes properly escaped. So, to be pragmatic, and make progress, I have merged to master, and will raise myself a separate ticket to investigate proper escape sequences on the 3 major platforms. |
Sounds like a great plan to me :-) |
Hi Sascha, thanks for this. I just tested our app on Linux using: Empty list and can confirm that CTK passes to the command line module the correct string. I think my confusion stems from the fact that I was testing with a bash script as a command line module, so it was the bash script that was reporting the strings incorrectly. Sorry. |
For issue commontk#307.
For issue commontk#307, as user may have explicitly removed the default.
If an argument requires a string, then an empty string is invalid when passed to the LocalProcess back end.
i.e. if you pass --myParameter1 --myParameter2 Banana
and the command line program expects something between --myParameter1 and --myParameter2, it will fail. The solution should be that if no text is specified, the text --myParameter1 is not passed either.
The text was updated successfully, but these errors were encountered: