Ticket #3748 (new enhancement)
mksh as a subshell
Reported by: | gloomyquazar | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 4.8.33 |
Component: | mc-core | Version: | master |
Keywords: | subshell mksh | Cc: | |
Blocked By: | #3692 | Blocking: | |
Branch state: | no branch | Votes for changeset: |
Description
Hello.
On my desktop and notebook I use FreeBSD together with mksh, which I like for it's small size, robustness, security... Recently I got to know that MC supports only bash, (t)csh, zsh and something else as main shells, hence my mksh doesn't work as a subshell, I can't just switch with Ctrl+O and work there, so I had to postpone using MC for now. Is there a way to add mksh for supported shells? Without a subshell working in MC gets very unconvenient.
With regards,
Sergey P.
Attachments
Change History
comment:2 in reply to: ↑ 1 Changed 8 years ago by andrew_b
- Blocked By 3692 added
- Milestone changed from 4.8.19 to Future Releases
Replying to gloomyquazar:
It would be nice to also add support for general Bourne /bin/sh as a subshell.
comment:3 Changed 8 years ago by zaytsev
If mksh has an equivalent of precmd (which, I think, it does) and you can cook up a patch to support it that is not impossible.
comment:4 Changed 8 years ago by gloomyquazar
Maybe the function like this will do?
function precmd {
<put something here>
}
PS1="$(precmd) $PS1 "
comment:5 Changed 8 years ago by zaytsev
As I said, if you manage to provide a clean working patch, we might eventually get it in.
comment:6 Changed 8 years ago by gloomyquazar
Could you please check this patch? It works OK for me.
comment:9 in reply to: ↑ 8 Changed 4 weeks ago by d3m3t3r
Replying to zaytsev:
Somebody turned this in a PR:
Added support for ksh/oksh/mksh Korn shell variants.
comment:10 Changed 4 weeks ago by zaytsev
- Milestone changed from Future Releases to 4.8.33
I assume you tested it and it works for you?
- I'm surprised that the "precmd" part was so simple. Is that due to static prompt? Is supporting user prompt impossible / problematic?
- I'm not sure that ksh supports HISTCONTROL... Does it really? If yes, good news.
comment:11 Changed 4 weeks ago by d3m3t3r
I need to fix it for mksh which is actually dumber than other pdksh/openbsd based variants. mksh doesn't support HISTCONTROL either \x placeholders in PS1 and recognizes not just ENV but $HOME/.mkshrc too.
Couldn't find any "precmd" like functionality in any variant so I suppose user prompt is not possible.
Since mksh seems to be quite different from other variants, would you recommend using distinct SHELL_KSH and SHELL_MKSH types? Or perhaps use single SHELL_KSH type but specific mc_shell->name?
comment:12 Changed 4 weeks ago by zaytsev
Since mksh seems to be quite different from other variants
I would add SHELL_MKSH if it's different enough, and SHELL_OKSH / SHELL_PDKSH (whichever official names make sense, didn't look into it) for clarity - you can use multiple enum values for the same case.
Couldn't find any "precmd" like functionality in any variant so I suppose user prompt is not possible.
It would be great to have this as a comment. Otherwise our children will wonder...
mksh doesn't support HISTCONTROL
But the others do, or everything is trashed with our cd commands?
comment:13 Changed 4 weeks ago by d3m3t3r
First, thanks much for the feedback. I've split mksh support under its own SHELL_MKSH type since its features differ so much it makes sense to handle it separately.
Some overview: There seems to be several implementations of ksh around but all but mksh (MirBSD ksh https://github.com/MirBSD/mksh) are based on pdksh (Public Domain ksh), in particular ports of OpenBSD ksh, e.g. https://github.com/dimkr/loksh and https://github.com/ibara/oksh. pdksh supports \x codes, variable and command substitution in PS1, HISTCONTROL (ignorespace & ignoredups) and ENV variable for interactive shell rc-file. mksh, on the other hand, doesn't support \x codes in PS1 either HISTCONTROL. It supports ENV variable for interactive shell rc-file but if it's not set the shell also tries ~/.mkshrc.
comment:16 Changed 2 weeks ago by zaytsev
Sorry, I still don't have time to look into it deeper... but I wonder, can actually the plain POSIX sh be supported with the fallback? Maybe you have the answer since you looked deeper into it.
comment:17 Changed 12 days ago by d3m3t3r
but I wonder, can actually the plain POSIX sh be supported with the fallback? Maybe you have the answer since you looked deeper into it.
I don't think the precmd fallback emulation in mc supports the plain POSIX shell because it relies on the command substitution in PS1 which according to the specification (https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_05_03) is unspecified.
comment:18 Changed 11 days ago by d3m3t3r
There's summary of the changes in my PR:
- Add support for mksh - uses fallback precmd emulation.
- Add support for pdksh-based ksh (e.g. OpenBSD's ksh) - supports user prompt.
- Enhance fallback precmd emulation to support user prompt (affect ash/dash/mksh).
I tested on Alpine Linux with busybox, dash, mksh, oksh (OpenBSD's ksh port) and loksh (another OpenBSD's ksh port) packages.
It would be nice to also add support for general Bourne /bin/sh as a subshell.