Skip to content

Consider providing easy way to override argv[0] #112

@lread

Description

@lread

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:

  1. specifying an -l or --login option to bash
  2. overriding argv[0] with a - prefix. For example, launching /bin/bash results in overriding argv[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 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:

  1. 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).
  2. 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.
  3. ?? 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions