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

Change cmd parameter in ExecuteProcess #263

Open
ivanpauno opened this issue Jun 13, 2019 · 5 comments
Open

Change cmd parameter in ExecuteProcess #263

ivanpauno opened this issue Jun 13, 2019 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ivanpauno
Copy link
Member

Feature request

Feature description

The current format of cmd is a little confusing. e.g.:

ExecuteProcess(['ls -las'])  # fails
ExecuteProcess(['ls -las'], shell=True)  # Ok
ExecuteProcess(['ls', '-las'])  # Ok
ExecuteProcess(['ls', '-las'], shell=True)  # Ok

That is maybe not of much interest, but the following case:

ExecuteProcess(['command', EnvironmentVariable('USER_ARGUMENTS')])

It's not way of specifying more than one argument in that environment variable, e.g.:

export USER_ARGUMENTS="-opt1 -opt2 -opt3"

That will make the program crash. The same problem applies for any substitution.
I don't see a possible workaround for that (without forcing shell=True).

My idea is to change the cmd type from:

cmd: Iterable[SomeSubstitutionsType]

to:

cmd: SomeSubstitutionsType

And use shlex.split after the substitutions are performed.

For backwards compatibility, we could accept both:

cmd: Union[SomeSubstitutionsType, Iterable[SomeSubstitutionsType]]

I realize about the problem while working in the launch frontend: #226 (comment).

@ivanpauno ivanpauno added the enhancement New feature or request label Jun 13, 2019
@ivanpauno
Copy link
Member Author

@hidmic FYI

@wjwwood
Copy link
Member

wjwwood commented Jul 24, 2019

That solution seems reasonable to me.

@hidmic
Copy link
Contributor

hidmic commented Jan 9, 2020

There's a bit of an issue with this change. We're essentially forcing shell-like parsing on otherwise plain command line arguments. And thus, something like cmd=['ls', 'my/subdir/with spaces/'] would stop working the way it currently does. Same goes for prefixes, where we already are shlex.split'ing them. We probably need a flag for the user to explicitly opt-in (or opt-out) this parsing behavior.

@ivanpauno
Copy link
Member Author

There's a bit of an issue with this change. We're essentially forcing shell-like parsing on otherwise plain command line arguments. And thus, something like cmd=['ls', 'my/subdir/with spaces/'] would stop working the way it currently does. Same goes for prefixes, where we already are shlex.split'ing them. We probably need a flag for the user to explicitly opt-in (or opt-out) this parsing behavior.

I see. So, though it's true that it's not 100% backwards compatible, I think that the change is still reasonable and won't affect much users (and the ones affected should be able to fix the problem easily).

@hidmic
Copy link
Contributor

hidmic commented Jan 9, 2020

We should probably also support a single string then e.g. cmd='ls "my/subdir/with spaces/"'. WDYT? That's the original suggestion, nvm.

roger-strain pushed a commit to roger-strain/launch that referenced this issue Sep 7, 2020
Modified handling of cmd parameter as described in ros2#263

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>
roger-strain pushed a commit to roger-strain/launch that referenced this issue Jan 25, 2021
Modified handling of cmd parameter as described in ros2#263

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>
mlanting pushed a commit to roger-strain/launch that referenced this issue Sep 30, 2021
Modified handling of cmd parameter as described in ros2#263

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>
mlanting pushed a commit to roger-strain/launch that referenced this issue Sep 30, 2021
Modified handling of cmd parameter as described in ros2#263

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>
mlanting pushed a commit to roger-strain/launch that referenced this issue Oct 28, 2021
Modified handling of cmd parameter as described in ros2#263

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>
hidmic pushed a commit that referenced this issue Oct 29, 2021
* Adding Executable description class

Part of implementation of refactor for #114

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>

* Cleaned up access to substituted values

Modified handling of cmd parameter as described in #263

Distro A; OPSEC #2893

Signed-off-by: Roger Strain <rstrain@swri.org>

* Initial implementation of execute_local

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Fixed minor bugs to verify unit tests

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Unit test fixes

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Adjust for launch_ros modifications, add unit tests

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Apply minor updates to address feedback

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Refactor arguments to apply to executable

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Fix order of parameters

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Fixed default log name prefix

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Fix unit tests

Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>

* Removed some language from file headers

Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: matthew.lanting <mlanting@dcscorp.com>

* Add prefix filtering to Executable description class.

Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: matthew.lanting <mlanting@dcscorp.com>

* Formatting fixes.

Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: matthew.lanting <mlanting@dcscorp.com>

* Fixed indentation in descriptions/executable.py.

Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: matthew.lanting <mlanting@dcscorp.com>

* Fixed namechange missed during rebase.

Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: matthew.lanting <mlanting@dcscorp.com>

Co-authored-by: Roger Strain <rstrain@swri.org>
Co-authored-by: matthew.lanting <mlanting@dcscorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants