mrsh icon indicating copy to clipboard operation
mrsh copied to clipboard

Proposal: rename shell/ to engine/

Open emersion opened this issue 5 years ago • 10 comments

This would allow us to move the shell implementation in shell/ (main.c, frontends…), while having libmrsh material in parser/ and engine/.

emersion avatar Nov 09 '18 20:11 emersion

-1

ddevault avatar Nov 09 '18 20:11 ddevault

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.

emersion avatar Nov 09 '18 20:11 emersion

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?).

ddevault avatar Nov 09 '18 20:11 ddevault

Yeah, that's a good idea. What about the mrsh executable itself? (main.c + frontends)

emersion avatar Nov 09 '18 20:11 emersion

I say leave it at the top-level.

ddevault avatar Nov 09 '18 20:11 ddevault

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.

emersion avatar Nov 12 '18 19:11 emersion

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.

ddevault avatar Nov 12 '18 19:11 ddevault

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).

ddevault avatar Dec 27 '18 05:12 ddevault

Right now shell/ is part of libmrsh. I wonder if we want this stuff to be part of the library.

emersion avatar Dec 27 '18 09:12 emersion

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.

ddevault avatar Dec 27 '18 16:12 ddevault