ref: 41ead0f046b94515afa805ed67da4e82d38b028f mrsh/shell/task/task.c -rw-r--r-- 10.7 KiB
shell/trap: reset traps in subshells

> When a subshell is entered, traps that are not being ignored shall be set to
> the default actions, except in the case of a command substitution containing
> only a single trap command, when the traps need not be altered.

References: https://github.com/emersion/mrsh/issues/137
builtin: add very basic trap implementation
Make the shell responsible for destroying terminated jobs

Builtins call mrsh_run_program but don't want to destroy the current job
in the middle of the execution (which may be marked as terminated
because no process is running).

In the future, we'll probably want to let shells inspect the job list
before destroying terminated jobs (and maybe customise the notification

Closes: https://github.com/emersion/mrsh/issues/122
Refresh jobs status after executing command

This allows us to notice that a process has finished without needing to
explicitely wait for it.
Print background job status notifications

Closes: https://github.com/emersion/mrsh/issues/108
Perform complete word expansion on for clause words

Also add a few new tests to make sure we don't break this.

Closes: https://github.com/emersion/mrsh/issues/125
Hide internal mrsh_call_frame details
Move a lot of internal state to mrsh_state_priv
Move all job control related stuff to mrsh_state_priv
Move mrsh_state.child to mrsh_state_priv
Prefix structs in headers
shell: hide definitions of mrsh_{variable,function}
shell/task: use word_to_pattern when running case clauses

This allows us to correctly handle quoted parts of the pattern.
shell/word: prevent field splitting on the result of tilde expansion
shell/task/word: don't perform tilde expansion in run_word
Don't perform pathname expansion on quoted strings

Closes: https://github.com/emersion/mrsh/issues/24
mrsh_state: move loop control into call frame
Change fprintf(stderr, …, strerror(errno)) to perror
shell/task: perform pathname expansion on for loop words

Closes: https://github.com/emersion/mrsh/issues/83
shell/task: simplify case clause matching
shell/task: fix case not handling quoted strings

Executing a case with a quoted string in a pattern resulted in:

    mrsh: ../ast.c:343: mrsh_word_get_string: Assertion `word->type == MRSH_WORD_STRING' failed.