You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, and foremost, thanks for pty4j, it is a very useful lib!
Disclaimer
My understanding is just that and could be wrong.
I am happy to learn if/where I've gone astray.
Use Case
I am contributing to an experimental open-source terminal that uses pty4j.
On macOS, due to the way Apple implemented shell initialization, it seems it is best practice to launch the shell for a terminal as a login shell.
This can be done via:
specifying an -l or --login option to bash
overriding argv[0] with a - prefix. For example, launching /bin/bash results in overriding argv[0] from /bin/bash to -bash.
While I do see pty4j has an exec method in com.pty4j.unix.PtyHelpers that looks like it would allow me to override argv[0] via its argv parameter, using it directly seems to mean I would lose the benefits of com.pty4j.unix.UnixPtyProcess.
Proposal
Make it easier to override argv[0].
Here are some initial ideas:
For me, ideally, this would be via a new option in one/more of the exec methods in com.pty4j.PtyProcess. Perhaps something named argv0Override? I don't think this is valid for Windows, so on that OS, if specified, it could be ignored (or throw, whatever makes sense).
Another alternative that might be workable is making exec in com/pty4j.unix.UnixPtyProcess public and override-able. This, I think, would allow me to replace exec behaviour to do my argv[0] override bidding.
?? Does anyone else see another good option I am missing?
Next steps
If this makes sense and is of interest, I could take a crack at a PR after we agree on an approach.
The text was updated successfully, but these errors were encountered:
No prob! Sorry for my slow response to your delayed response. 🙂
Thanks, as I can see, kitty adds - prefix. Are there any benefits of prepending shell name with - over passing --login?
I don't really know enough to answer that, but it seems like most terminal implementations opt to use the - pretending trick, so I figured we should follow suit.
Perhaps this technique is more generic/transparent across more shells?
Have you tried to prepend shell name with a dash and pass it to com.pty4j.PtyProcessBuilder#setCommand?
No, I thought that would not work because we eventually get to this invocation:
which I think would try to invoke a cmd[0] with the dash prefix which would fail.
My 2nd proposal was a clever (?) idea to allow me to override just a wee portion (the exec method) of UnixPtyProcess to maybe (?) get the desired effect. If this seems viable and interesting, I could explore more.
Thanks
First, and foremost, thanks for pty4j, it is a very useful lib!
Disclaimer
My understanding is just that and could be wrong.
I am happy to learn if/where I've gone astray.
Use Case
I am contributing to an experimental open-source terminal that uses pty4j.
On macOS, due to the way Apple implemented shell initialization, it seems it is best practice to launch the shell for a terminal as a login shell.
This can be done via:
-l
or--login
option to bashargv[0]
with a-
prefix. For example, launching/bin/bash
results in overridingargv[0]
from/bin/bash
to-bash
.We looked at kitty, alacritty, iTerm2 and contour. They all picked option 2.
So we'd like to do the same.
Issue
While I do see pty4j has an exec method in com.pty4j.unix.PtyHelpers that looks like it would allow me to override
argv[0]
via itsargv
parameter, using it directly seems to mean I would lose the benefits ofcom.pty4j.unix.UnixPtyProcess
.Proposal
Make it easier to override
argv[0]
.Here are some initial ideas:
exec
methods incom.pty4j.PtyProcess
. Perhaps something namedargv0Override
? I don't think this is valid for Windows, so on that OS, if specified, it could be ignored (or throw, whatever makes sense).exec
incom/pty4j.unix.UnixPtyProcess
public and override-able. This, I think, would allow me to replaceexec
behaviour to do myargv[0]
override bidding.Next steps
If this makes sense and is of interest, I could take a crack at a PR after we agree on an approach.
The text was updated successfully, but these errors were encountered: