I solved it!

Instead of using 'su -m' now I use 'su -m root -l'.

It seems that tcsh is launced by default as "interactive shell" while ksh must be explicitly instructed with the '-l' flag.

Now, as "interactive shell", it re-read the .profile configuration with aliases and all...

Thanks


On 7/30/22 11:46, Alexander Hall wrote:


On July 30, 2022 9:18:34 AM GMT+02:00, Federico Giannici <[email protected]> 
wrote:
For historical reasons I always used the tcsh shell for my personal uses. Now 
I'd like to switch to the system sh (actually ksh), but I have a problem.

Usually, on the servers I manage, I switch to root with "su -m", so I can 
maintain my environment: path, prompt, aliases, etc.

With tcsh it works perfectly, but if I use sh (ksh) all the aliases are lost in 
the root environment.

Is it expected this different behavior between tcsh and ksh?

Is there a way to maintain the aliases when i do "su -m" with sh?

Is there some kind of "exportation" of aliases? In the ksh man page it says that the "-x" 
option of alias "sets the export attribute of an alias", but it doesn't seem to have any effect. 
How is it supposed to work?

I doubt you're really exporting the aliases per se. More likely tcsh is 
sourcing your alias definitions from some file(s). Files like .profile, .login, 
.kshrc etc are sourced in different ways in different shells. For details, 
consult the ksh man page.

/Alexander


Thanks.

P.S.
I'm talking about OpenBSD amd64 7.0 and 7.1.



Reply via email to