BASH SHELL; DEBIAN STRETCH
As seen here, I've created a "seems to work OK, most of the time" alias function for the su command (actually, I'm not able to find any problems with it...yet). I've inserted it into my /etc/bash.bashrc file.
function su() { if [[ $1 == "--" ]]; then command su "$@"; else command su -l "$@"; fi; }
However, I know it could probably stand some improvement.
(What I want this function to accomplish is rather simple. If I could use regular aliases, I'd want something like:
alias su='su -l
AND alias 'su --'=su
However, I realize that the name of an alias can't have spaces...and the logic seems a bit circular...)
Does my shell function have any hidden traps? Will it negatively affect the operation of "su" if a different option is called (e.g. "su -c")?
alias su='su -l
, but I also wantalias 'su --'=su
. – Digger Mar 29 '23 at 04:35--
if the function is invoked with--
as the first argument, and then callsu
with the remaining arguments? – Kusalananda Mar 29 '23 at 04:35