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" }
When you use
command ...orexec "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
putssomething before callingexec.