As stated in the title, I need to determine when a program is ran if the path is relative or absolute:
./program #relative
dir/dir2/program #relative
~User/dir/dir2/program #absolute
/home/User/dir/dir2/program #absolute
This are my test cases. How exactly could I go about doing this in a shell program?
Or more generally, how to check if a path, $0
in this case, is relative or absolute?
~
before it runs the script, so you only need to check for a leading/
– Dispersion./~User
-- if that's not what you mean, then the quoting is completely a red herring. – Vere