mrsh
mrsh copied to clipboard
Proposal: rename shell/ to engine/
This would allow us to move the shell implementation in shell/
(main.c
, frontends…), while having libmrsh material in parser/
and engine/
.
-1
Is this because you don't like the name? Or is this because you don't like the subdir?
Right now in /
we have mixed libmrsh, mrsh executable and other executables.
Both. I think that shell is an adequate description of what that directory currently does. I'd prefer to move the non-mrsh executables into another directory (examples?).
Yeah, that's a good idea. What about the mrsh executable itself? (main.c
+ frontends)
I say leave it at the top-level.
I think that shell is an adequate description of what that directory currently does.
Actually, not really. The shell is the whole thing. This directory only contains a library that takes an AST and runs it.
Disagree. Just because it takes the form of a library doesn't mean it's not a shell. main.c
hardly does anything at all, and I think the top-level entry-point belongs at the top-level. I maintain my position.
main.c is getting bigger. We should perhaps consider moving some of it into shell/entry.c (e.g. PS* handling, sourcing profile, populating the environment, etc, but probably not the REPL).
Right now shell/
is part of libmrsh. I wonder if we want this stuff to be part of the library.
I think some of it fits and some of it doesn't, would have to be done with discretion. Here's my proposal for the header:
#ifndef _MRSH_ENTRY_H
#define _MRSH_ENTRY_H
#include <mrsh/shell.h>
/**
* Expands $PS1 or returns the POSIX-specified default of "$" or "#". The caller
* must free the return value.
*/
char *mrsh_get_ps1(struct mrsh_state *state);
/**
* Expands $PS2 or returns the POSIX-specified default of ">". The caller must
* free the return value.
*/
char *mrsh_get_ps2(struct mrsh_state *state);
/**
* Copies variables from the environment and sets up internal variables like
* IFS, PPID, PWD, etc.
*/
void mrsh_populate_env(struct mrsh_state *state);
/**
* Sources /etc/profile and $HOME/.profile. Note that this behavior is not
* specified by POSIX. It is recommended to call this file in login shells
* (for which argv[0][0] == '-' by convention).
*/
void mrsh_source_profile(struct mrsh_state *state);
/** Sources $ENV. Note that this behavior is not specified by POSIX. It is
* recommended to source this file in interactive shells. */
void mrsh_source_env(struct mrsh_state *state);
#endif
I think we should also move get_alias into shell or parser rather than making the user specify it by default.