[ros-users] [Ros-developers] suggest new ros shebang command
kruset at in.tum.de
Thu Aug 11 13:38:32 UTC 2011
> > I briefly thought about just adding the functionality to rosrun or rosh,
> > just to keep an open mind.
> If we add it to rosh, what about the lisp use case?
If rosh were by default placed in ros/bin, and would be relaxed about
the commenting of the second shebang line, no problem, I guess. We sure
don't wish for a dependency of roslisp packages to rosh packges, just to
> > For roslaunch the package argument is optional, it could be optional for
> > rosrun.
> > And rosrun could check whether it runs a script, whether there is a
> > second shebang line (made unique by additional symbols), and if so run
> > the file with the given script interpreter and args.
> In order to add it to rosrun, it would have to be added to roslaunch as well.
I am not sure about this. I thought about it some more, and I quite like
the rosrun integration. rosrun would then have two syntaxes for usage:
Usage: rosrun PACKAGE EXECUTABLE [ARGS]
or: rosrun FILENAME <no arguments>
To forbid arguments for the second usage is justified, as this is only
useful for shebang lines anyway.
With the latter usage, rosrun would check whether the file is an
executable #! script and invokes rosrun in the first, e.g
startswith(#!) and endswith(rosrun)
or something stricter, and if so expect a second shebang line, else
So if we have a script like this:
#! /usr/bin/env rosrun
;; /usr/bin/env rosrun sbcl run-sbcl.sh --script
roslaunch would do what it always does, execute with Popen.
Popen calls execvp on the shebang line
execvp executes rosrun
rosrun recognized it's being invoked with just a filename
rosrun recognizes it is mentioned in the shebang line
rosrun calls execvp on the second shebang line
execvp executes rosrun again
rosrun is being invoked with many arguments and does what it always did
Not the quickest way to start a script, but possible.
So no explicit change to roslaunch is required here, I think.
More information about the ros-users