I was wondering if there's a way to find out the default shell of the current user within a shell script?
Use case: I am working on a script that sets an alias for a command and this alias is set within a shell script.
!# /bin/bash
alias = 'some command to set the alias'
There's a logic in the script where it tries to find the default shell of the user that executes the script and adds this alias in the respective ~/.bashrc or ~/.zshrc file
But as I am adding a shebang in the front of the script and explicitly asking it to use bash, answers posted here always return bash as expected although I am executing this script on a ZSH terminal.
Is there a way to get the shell type where the script is executed regardless of the shebang set?
I am looking for a solution that works on both Mac and all the linux based bistro.
Best Answer