mrsh/builtin d---------
819e0495 — Issam Maghni 5 months ago
Nitpick details about buit-ins

* exec and trap are special built-ins
* Add remaining utilities as comments
* type now recognizes special built-ins
Make mrsh_getopt private
Check error even when mrsh_parse_program returns non-NULL

In the future, I'd like to make mrsh_parse_program return the
partially-parsed program on error to allow interactive shells to provide
syntax highlighting while typing.
ensure argv passed to getopt is NULL terminated

This has two fixes, 1: in push_frame allocates an extra array
element, and uses calloc instead of malloc to ensure that element is
NULL.  2: in argv_dup, enough memory is allocated but, the last element
is left uninitialized.  By using calloc instead, the last element is
guaranteed to be NULL.

I also added a test for this, although it does not always fail since it
relies on undefined behavior.
builtin/read: return 1 when an EOF is encountered

For instance:

    echo "hi" | read arg

should have an exit code of >0 per the POSIX spec.

A test was also added.

Closes: https://github.com/emersion/mrsh/issues/142
builtin/set: fix monitor option enabled when running script
builtin/set: toggle job control at runtime

Closes: https://github.com/emersion/mrsh/issues/113
builtin/trap: proper escaping when printing traps

References: https://github.com/emersion/mrsh/issues/137
builtin: add exec implementation
builtin/trap: add support for XSI numeric signal names
builtin/trap: fix FreeBSD build

SIGVTALARM is an XSI extension. SIGPOLL is unimplemented.
builtin: add very basic trap implementation
builtin/export: make readonly -p only print read-only params

Closes: https://github.com/emersion/mrsh/issues/132
Print background job status notifications

Closes: https://github.com/emersion/mrsh/issues/108
Hide internal mrsh_call_frame details
Use the len/cap wording in collect_vars
Make mrsh_collect_vars private
Move a lot of internal state to mrsh_state_priv
Move all job control related stuff to mrsh_state_priv
Prefix structs in headers
build: add -Wmissing-prototypes