The following case:
LBUFFER='zstyle -'
RBUFFER=' foo bar'
Before this patch, completed 'context pattern' (from the first
positional argument).
With this patch, completes options, which is correct.
Factored out from the next patch for readability of the diff.
The answer, as it stands in this commit, doesn't flow correctly. In
order to keep the diffs small and easy to follow, this commit simply
adds a TODO to record this issue, a TODO which is fixed by the next
commit in this series (the child of this commit). Thus, a request:
DEAR PEOPLE FROM THE FUTURE: Please don't create new branches off this
commit; create them off the parent commit or off the child commit
instead. Thank you.
* Rename zstyle `cleanup' on the context `:prompt-theme' to `restore'
everywhere but in prompt_cleanup(). It is only used as a restore
mechanism now.
* Ensure prompt_cleanup() continues to store its command list in the
`cleanup' style.
* Clean up before theme switch at the end of set_prompt().
* Prepend every use of prompt_*_setup (which might modify the shell
state in ways that require cleanup) with a cleanup run.
* Adjust `prompt restore' to do both parts of the newly split restore
mechanism, cleanup first.
This change modifies the zsh binary safety check surrounding execve() so
it can run shell scripts having concatenated binary content. We're using
the same safety check as FreeBSD /bin/sh [1]. POSIX was recently revised
to require this behavior:
"The input file may be of any type, but the initial portion of the
file intended to be parsed according to the shell grammar (XREF to
XSH 2.10.2 Shell Grammar Rules) shall consist of characters and
shall not contain the NUL character. The shell shall not enforce
any line length limits."
"Earlier versions of this standard required that input files to the
shell be text files except that line lengths were unlimited.
However, that was overly restrictive in relation to the fact that
shells can parse a script without a trailing newline, and in
relation to a common practice of concatenating a shell script
ending with an 'exit' or 'exec $command' with a binary data payload
to form a single-file self-extracting archive." [2] [3]
One example use case of such scripts, is the Cosmopolitan C Library [4]
which configuse the GNU Linker to output a polyglot shell+binary format
that runs on Linux / Mac / Windows / FreeBSD / OpenBSD.
[1] 9a1cd36331
[2] http://austingroupbugs.net/view.php?id=1250
[3] http://austingroupbugs.net/view.php?id=1226#c4394
[4] https://justine.lol/cosmopolitan/index.html