Reputation: 83680
I want to run a command with inline comment like
sleep 1 # first sync call
sleep 1 # second sync call
# etc
But I can't pass it to exec
in Ruby
fork{ exec "sleep 1 # first async call" }
fork{ exec "sleep 1 # second async call" }
It traces warnings.
So how could I pass some comments into system call with exec
.
I need it for logging
PS: As a variant: fork{ exec "sh -c 'sleep 1' # first async" }
Upvotes: 0
Views: 307
Reputation: 118761
When you use
or command ...
exec "command ..."
, everything after the first word is used as arguments to the command, so your comment is not being interpreted as a comment.
Regardless, your logging wouldn't be able to capture this, since it's only a comment — instead, you might just want to puts
something before calling exec
.
Upvotes: 2