Bug 67971

Summary: systemd-run splits ARGS with spaces
Product: systemd Reporter: redneb <redneb>
Component: generalAssignee: Zbigniew Jedrzejewski-Szmek <zbyszek>
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description redneb 2013-08-10 03:37:56 UTC
When I am issuing the following command
  systemd-run /bin/sh -c 'sleep 5'
it doesn't work as expected, instead it gives the following:

Aug 09 23:18:00 vmg systemd[1]: Starting /bin/sh -c sleep 5...
Aug 09 23:18:00 vmg systemd[1]: Started /bin/sh -c sleep 5.
Aug 09 23:18:00 vmg sh[537]: sleep: missing operand
Aug 09 23:18:00 vmg sh[537]: Try 'sleep --help' for more information.
Aug 09 23:18:00 vmg systemd[1]: run-536.service: main process exited, code=exited, status=1/FAILURE
Aug 09 23:18:00 vmg systemd[1]: Unit run-536.service entered failed state.

It seems that systemd-run splits the 'sleep 5' and executes
  /bin/sh -c sleep 5
instead of
  /bin/sh -c 'sleep 5'

Is this the expected behavior?
Comment 1 Harald Hoyer 2013-08-30 10:15:35 UTC
Workaround for now:

# systemd-run /bin/sh -c \'sleep 5\'
or
# systemd-run /bin/sh -c "'sleep 5'"
Comment 3 Zbigniew Jedrzejewski-Szmek 2013-09-09 18:58:26 UTC
Fixed in http://cgit.freedesktop.org/systemd/systemd/commit/?id=a6fde353.
Comment 4 Harald Hoyer 2013-09-10 08:42:06 UTC
You remove the empty "ExecStart=", which basically clears all previous ExecStart!

- fputs("ExecStart=", f);

Please add it back.
Comment 5 Zbigniew Jedrzejewski-Szmek 2013-09-10 11:21:32 UTC
(In reply to comment #4)
> You remove the empty "ExecStart=", which basically clears all previous
> ExecStart!
> 
> - fputs("ExecStart=", f);
> 
> Please add it back.
Hm, I admit that I'm not sure what the empty ExecStart line is for, don't we create the unit from scratch and can't we put anything we want in the ExecStart line right from the beginning?

Nevertheless, I didn't touch it. If I do:

sudo systemd-run /bin/sleep " 100000"

I have:

==> /run/systemd/system/run-3233.service.d/90-ExecStart.conf <==
[Service]
ExecStart=
ExecStart=@/bin/sleep "/bin/sleep" " 100000"

and before my changes:

==> /run/systemd/system/run-4335.service.d/90-ExecStart.conf <==
[Service]
ExecStart=
ExecStart=@/bin/sleep /bin/sleep  100000

Seems to be the same, module the bug, or am I missing something?

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.