I am using a bash script to launch a ruby script.
this works very well if you are in the sir of the script but if you are not in that dir the script acts funny because it is not on the file path.
#!/bin/sh
jruby -Ilib script.rb $@
I added this to the script.
mypath=`realpath $0`
cd `dirname $mypath`/..
It makes the script run from any place I want. the problem is that its arguments do not get their relative path names changed.
I am using trollop for my input parsing.
My question is: How can I change the input of the path in the input so it will be the correct relative path when I push the args to the ruby script.
I would be happy with a ruby fix to this problem.
This uses bash specifically. It assembles an array of the arguments, calling
realpathfor each.I’ve liberally sprinkled double quotes throughout the script to handle files and paths that contain spaces.