mrsh/builtin/set.c -rw-r--r-- 5.8 KiB
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/set: fix monitor option enabled when running script
builtin/set: toggle job control at runtime

Closes: https://github.com/emersion/mrsh/issues/113
Make mrsh_collect_vars private
mrsh_state: rename args field to frame
builtin/set: implement set -o to print all options
Only create jobs if job control is enabled
Replace EXIT_* constants with integers
Fix state->args not set
Move away from FILE

Fixes https://github.com/emersion/mrsh/issues/58
Set CLOEXEC on all opened FDs
Implement arg stack for functions
Add optional readline/libedit support

This adds support for line editing, history, etc, either with GNU
readline or BSD libedit. Also adds support for $PS2.
builtin: fix various issues found by static analysis
Implement export builtin
Introduce mrsh_variable
Avoid null dereference in argv_free
builtin: introduce mrsh_process_args
builtin: add missing \n to `set` error message
shell: add alias support
Complete implementation of set builtin