The dependency is injected via a field in shell.Program.
Also add an alternative entrypoint, cmd/nodaemon/elvish, which does not include
the daemon server or client.
The `edit:after-command` hooks are called with a single argument:
a pseudo-map with these keys:
"command": the command line that was run
"duration": the execution duration in seconds
"error": any error that occurred ($nil if no error occurred)
The `edit:command-duration` variable is the elapsed seconds (as a
float64) of the most recently run interactive command.
Resolves#1029
* Move all widget types to a new pkg/cli/tk.
* Move Mode{Line Prompt} to a new pkg/cli/mode.
* Move all packages in pkg/cli/addons to pkg/cli/mode.
* Remove WriteListing.
* Remove StdTTY.
* Rename GetCodeBuffer to CodeBuffer.
* Introduce the `path:` module
This is based on https://github.com/elves/elvish/pull/1084 by @kolbycrouch
submitted five months ago. It addresses all of the feedback on that
change and includes other documentation and unit test improvements. It
also includes a couple of extensions to the original P.R., such as a
`path:is-abs` command.
I decided to resurrect that change because I want better support for
filesystem path manipulation so that users can replace non-portable
external commands such as `realpath` and `find` with Elvish builtins. This
is a baby step towards that goal.
Related #849
* Add a `path:is-regular` command
This adds a `path:is-regular` command. This is for symmetry with the
`path:is-dir` command and the glob `[type:regular]` modifier.
It also adds support for symlinks in the `testutil.Applydir` function
and change the path unit test to use it.
* Rename path:real to path:eval-symlinks
The Elvish daemon should not inherit file descriptors open on the tty.
Make the daemon's stdin open on the null device and its stdout/stderr
open on a predictable file.
Fixes#1191
This change makes Ns immutable from the exposed API. Internally there is exactly
one place that still mutates Ns, in scopeOp; this will be addressed later.
- Make Evaler mostly thread-safe. The only remaining thread-unsafe part is the
modules field, which is more tricky than other fields.
- Remove the state and evalerScopes type, and move their fields into Evaler.
- Expose valuePrefix via a get method, and change PortsFromFiles to take the
prefix instead of a *Evaler. Also expose a PortsFromStdFiles.
- Make Evaler a normal field of Frame, instead of an embedded field. This makes
access to global states more explicit.
The new (*Evaler).Check method allows the implementation to be simpler.
Also test the JSON format feature in an integration test instead of unit test;
this makes it unnecessary for the eval package to expose NewCompilationError.
This method has the property that it always tries to compile the code even if
there is a parse failure. This is the more desirable behavior when checking
code: if there is a parse failure near the end of a chunk of code, the user may
like to learn about compile errors earlier in the code.
As with commit #eb2a792 I acknowledge that `golint` recommendations are
controversial and should not automatically be acted on. Nonetheless,
this change fixes legitimate lint issues such as copy/paste cleanups,
style problems I introduced (`i += 1` versus `i++`) or method/var comments
that are not in the preferred form.
While working on my next commit, to prevent I/O deadlocks, I experienced
some problems because I had a syntax error in the Elvish code to generate
the output. That wasn't immediately obvious because I had copied another
test that only tested the stdout of the shell and the syntax error was
written to stderr. This change modifies existing tests to verify both
stdout and stderr have the expected content.
Note that there are three interactive tests for which we still do not
verify the content of stderr. That's because stderr for those tests only
contains a shell prompt whose content changes each time the test is run.
TBD is modifying the interactive tests to have a predictable prompt.
Since elvish does not support job control it should run all external
commands with the tty job control signals set to be ignored. See "APUE",
third edition, page 379.
This doesn't actually fix the problem in the case of broken programs
like vim which blindly assume the parent process implements job control.
But there isn't much we can do about that other than try to get those
programs to pay attention to being told to ignore SIGTSTP.
Fixes#988
While debugging my fix for issue #661 I noticed that a panic that invokes
the `rescue` function causes Go to think the test passed due to launching
a rescue shell. This introduces a mechanism for elvish unit tests to
request that panics be fatal; i.e., exit with a non-zero status rather
than launch a rescue shell.
This also changes the behavior of panics by non-interactive elvish
shells to no longer launch an unexpected rescue shell.
This will likely become a basic operation in future that can support more types
than exceptions, so putting it in the builtin namespace is appropriate.
Also remove the exc: module altogether as it contains nothing now. All the
introspection features are now implemented as fields of the exception values and
the reason values.