How to add subshell support for ash

Alexander Kriegisch kriegaex at freetz.org
Sat Mar 3 13:41:39 UTC 2012


I am on an embedded environment. Bash is available as a separate
package, but huge in comparison with the built-in ash of BusyBox.

Disclaimer before I continue: I am *not* a C programmer. I can read a
bit of C, but not develop anything meaningful other than copy, paste and
modify existing code. So bear with me anyway, if you please.

I looked into src/subshell.c and tried to figure out what happens there.
I have started to add ash support, but MC seems to depend on
PROMPT_COMMAND/precmd/fish_prompt, i.e. on a function or alias which is
executed each time just before a prompt is printed. Ash does not have
anything like that, AFAIK. If I understand correctly, using those
pre-commands are MC's way of determining the cwd. I wonder why you do
not just use something like pwd or $PWD, but OTOH I do not understand
the difficulties of corresponding with the subshell.

Anyway, in my case it would be absolutely fine to set a fixed value of
PS1='\w\$ ' for the subshell and read the cwd from the prompt. In any
case it would be better than not having the option of using ash as a
subshell at all.

Could anyone maybe provide me with a code snippet or a patch which shows
me how to extract the cwd from the prompt assuming that PS1 has the
value '\w\$ '? (BTW, '\$' will be evaluated to '$' or '#' in ash,
depending on whether you are root or not.)

Thank you so much. If I succeed in adding ash as a subshell, I will
provide a (raw) patch for you to inspect and maybe refine and include
upstream.

Thanks in advance and kind regards
-- 
Alexander Kriegisch



More information about the mc-devel mailing list