I want to write a script, to be packaged into a gem, which will modify its parameters and then exec
a new ruby process with the modified params. In other words, something similar to a shell script which modifies its params and then does an exec $SHELL $*
. In order to do this, I need a robust way of discovering the path of the ruby executable which is executing the current script. I also need to get the full parameters passed to the current process - both the Ruby parameters and the script arguments.
The Rake source code does it like this:
RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).
sub(/.*\s.*/m, '"\&"')
If you want to check on linux: read files:
Other useful info can be found in /proc/PID dir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With