Improved subshell support (was: How to add subshell support for ash)
Alexander Kriegisch
kriegaex at freetz.org
Wed Mar 7 00:32:11 UTC 2012
Hi!
I discovered that there is a Trac ticket system on your web site, but
somehow my provider's mail server seems to filter out registration
e-mails, maybe because of a non-existent noreply at ... sender address.
Maybe someone can activate my e-mail address (user name kriegaex)
manually? Anyway, for the time being I will keep posting here in this
thread instead of creating a ticket with attachments in Trac:
I think I have resolved the remaining issues with differentiating
between BusyBox ash and Debian ash (dash). I also refactored the
subshell code and documentation a bit for all subshell types. I
installed and tested *all* of them on my Ubuntu 11.10 64-bit desktop
system plus Bash and BusyBox ash on my embedded mipsel platform.
I think now I have reached a mature enough code state for you to commit
it upstream because everything which worked before still does and
several things which were buggy or unavailable have been fixed/added.
The patches currently contain the following changes:
030-bash_inputrc.patch
- Fix non-functional INPUTRC for bash (variable was unset and never
used)
040-ash_as_subshell.patch
- Fix chdir for fish: communication with subshell was not working and
showing an error message because "pwd" returns abbreviated home
directory "~" instead of full path name. So now we use "$PWD" and
it works. This must have been broken for a while. This is unrelated
to ash, but I included it in the refactoring patch for
src/subshell.c anyway because it is small and the same code section
was also changed for other reasons (set fish prompt).
- All subshells now have a dynamic, meaningful prompt user at host:cwd.
This was tricky for ash/dash and a little easier for the other
shells.
- Shell type recognition for automatic subshell selection has been
improved: Now not only the SHELL names are checked, but also their
link targets in order to determine the correct type (e.g. if a ksh
is really a zsh or if an ash is BusyBox or dash, if sh is whichever
type or if bash is symlinked to BusyBox (but BB still is just an
ash, never a bash). Even if the type could not be determined or a
compatible subshell not found via inspection of SHELL and
/etc/passwd, function OS_Setup in main.c now searches for known
shells by their usual paths. For instance, if you have an exotic
login shell called foosh, you can now have subshell support anyway,
if MC finds an ash, bash etc. in the system.
- I have added many more comments to the code sections I changed.
Maybe some of you think there are too many now, but I think this
tricky part of the code base should be documented rather too much
than not wnough, so as to make it easiert for maintainers to
upgrade subshell support or add new subshell types in the future.
Sometimes it is not enough to have working code, but helpful to
understand *why* the code was written in a certain way.
040-ash_as_subshell_additional.patch
- ashrc init file added to config file list
- Subshell documentation page updated with a few corrections, better
formatting and some new information (doc/man/mc.1.in), e.g. how to
use init files for bash and ash, how to manually call mc with SHELL
variable set to another shell type if you want to have a specific
subshell type.
BTW, the patches have been created for mc-4.8.1, *not* for the
trunk/master. But they should be easy to merge into the master.
All in all I believe that adding these patches to MC will significantly
improve subshell support, fixing two old issues and adding new subshell
types often used on servers or embedded systems. That could make MC even
more popular. E.g. I have heard from several people that they would like
to get rid feature-rich, but big shells like bash, zsh or tcsh on such
systems if they had busybox or dash subshell support. I think MC is far
from dead and did what I could with my humble means to improve a small
part of it.
Open issues (legacy, not created by my patches):
- Still open is the old issue of fish not reliably showing its prompt
in the bottom line of mc. With my limited knowledge I could not
find out why this happens, but I noticed an interesting fact: If I
start mc in an strace command line (I did this because I was
debugging/logging something during development), all of a sudden
the fish prompt is shown reliably on my test machine. Maybe strace
was slowing down something, so this might be a timing issue,
possibly a race condition, but this is just a guess. It might be a
starting point for further investigation by one of you guys.
- Another (old) open issue which still exists is that if you cd to
another directory in full-screen mode (hide panels with Ctrl-O),
then show the panels again with Ctro-O, the new path is not
immediately shown on the bottom line, but only after some user
interaction such as pressing Tab twice, switching back and forth
between left/right panel.
--
Alexander Kriegisch (kriegaex)
http://freetz.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 030-bash_inputrc.patch
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20120307/add6fd09/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 040-ash_as_subshell.patch
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20120307/add6fd09/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 040-ash_as_subshell_additional.patch
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20120307/add6fd09/attachment-0002.ksh>
More information about the mc-devel
mailing list