Re: Symlinks of sh to bash breaks extra args?

Joel Reicher <[email protected]> Tue, 23 Sep 2025 16:13:46 +1000
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
Michael Albinus <[email protected]> writes:

> Joel Reicher <[email protected]> writes:
>
>>> Users change tramp-default-remote-shell. And then, there is a 
>>> good chance to benefit from tramp-sh-extra-args.
>>
>> And that's kind of what I'm struggling with. I can see the 
>> default value for extra args caters for both bash and 
>> zsh. Let's imagine I have both; which one would be a "better 
>> Tramp buddy" as you say below?
>
> Both could be good buddies. When used with care (proper shell 
> arguments coming from tramp-sh-extra-args, sensitive settings in 
> .profile). But Tramp doesn't recommend any of them; it is up to 
> the user to change is she isn't happy with 
> tramp-default-remote-shell. /bin/sh is the minimal consensus we 
> could expect to exist remotely.

I was meaning to ask about tramp-default-remote-shell also. On my 
version of Tramp (2.7.3.30.2) it's not a defcustom and it's also 
not mentioned in the manual, so changing it doesn't seem to be 
"approved". Rather, the manual mentions customising 
tramp-connection-properties.

Is the default shell "supposed" to be changed?

>> And even as a third option I think invoking bash as sh enables 
>> some POSIX compatibility and disables some bash-specific 
>> features, so perhaps that's better still?
>
> What do you mean with this?

"When invoked as sh, Bash enters POSIX mode after reading the 
startup files."

https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html#Bash-POSIX-Mode-1

So it's possible this mode is an even better Tramp buddy than 
bash-as-bash with the extra args, but I don't know how to judge 
this. (Although the below suggests the opposite, which is exactly 
the kind of information I'm after.)

>> My problem here is that from what I can tell the remote shell 
>> is Tramp's agent, and I don't really know what helps Tramp the 
>> most. In the abstract I'm kind of a bit surprised it doesn't 
>> deploy a custom command loop with simple semantics implemented 
>> as an awk script or something like that. (Dependent on a good 
>> awk being available, of course.)
>
> There's tramp-find-shell, which does kind of. Could be improved, 
> of course, it is very rudimentary. And it still requires that 
> Tramp has connected to the remote already with 
> tramp-default-remote-shell.

That's very interesting. I think tilde expansion is exactly what I 
saw break on one of my remotes when the remote shell was /bin/sh, 
and the POSIX mode of bash does change tilde expansion. I didn't 
dig into the details enough to be sure that was the cause though.

Thanks and regards,

       - Joel