I am trying to write a file that a user will source in order to modify their ld_library path. This will be different for each shell so I need to find theirs before I do this.
I have tried:
$SHELL
Unfortunately this will give the users shell but not necessarily the shell that they are in. If my normal shell is BASH but I swap into sh, it will return /bin/bash.
readlink -f /proc/$$/exe
This looked promising unfortunately a shell script actually spawns a new instance of bash, or whatever you put with the #! at the start.
Finally:
$0
This actually returns the name of the executable, rather than the shell. Which makes sense but it works as a shell command.
Any suggestions?
EDIT: So all of the suggestions from a similar thread will either return what is the users preferred shell, they will return the name of the executable itself, or they will return the path for the #! at the start of the code. None of these are particularly helpful.