Commit Graph

17 Commits

Author SHA1 Message Date
Timothy Sample f22bc57996 Respect noclobber when redirecting.
* gash/shell.scm (process-redir): Respect the noclobber option.
* tests/redirects.org: Add a test.
2020-03-22 11:57:17 -04:00
Timothy Sample a0b6189cf3 Add basic support for asynchronous commands.
* gash/environment.scm (*last-job*): New variable.
(get-last-job): New procedure.
(set-last-job!): New procedure.
(reap-child-processes!): New procedure.
* gash/eval.scm (eval-sh): Handle '<sh-async>'.
* gash/gash.scm (main): Reap child processes.
* gash/repl.scm (run-repl): Likewise.
* gash/shell.scm (sh:async): New procedure.
* gash/word.scm (parameter-ref): Handle "!".
2020-03-17 17:15:36 -04:00
Timothy Sample 4f90afcd3d Use bindings with regular built-ins.
* gash/shell.scm (sh:exec-let): Save and set variables according to
'bindings' before executing a regular built-in.
2019-12-09 13:53:44 -05:00
Timothy Sample 8a440f35f6 Reap every process in a pipeline.
* gash/shell.scm (waitpid/any): New procedure.
(sh:pipeline): Use it to reap every process spawned while executing a
pipeline.
2019-12-09 13:36:41 -05:00
Timothy Sample d600f82f7f Do not leak ports into pipeline processes.
* gash/shell.scm (swap-and-shift-pairs): Remove procedure.
(make-pipes): Remove procedure.
(plumb): Accept another port as an argument and close it when setting
up the child process.
(sh:pipeline): Do not use 'make-pipes' to create all the pipe ports
upfront, but rather create them as needed and give them directly to
'plumb'.
2019-12-09 13:36:41 -05:00
Timothy Sample 121d9cb435 Close ports opened for redirects.
* gash/shell.scm (redir->parameter+port): Rename this...
(process-redirect): ...to this, and make it return a list with the
third element being a boolean indicating if the port was opened by us.
(sh:with-redirects): Close ports when the new boolean is set.
2019-12-09 13:36:41 -05:00
Timothy Sample d6a582f1bd Only throw for specific special built-in errors.
* gash/shell.scm (sh:exec-let): Do not throw on special built-in
errors.
* gash/built-ins/break.scm (main),
gash/built-ins/continue.scm (main),
gash/built-ins/return.scm (main),
gash/built-ins/shift.scm (main): Throw on error.
2019-12-08 12:18:31 -05:00
Timothy Sample 16ba8ca016 Use temporary assignments when calling functions.
* gash/environment.scm (save-variables-excursion): New procedure.
* gash/shell.scm (sh:exec-let): Use it to set up temporary assignments
during the extent of a function.
* tests/temporary-assignments.org: New file.
* Makefile.am (TESTS): Add it.
2019-11-24 17:13:54 -05:00
Timothy Sample 9639f5eff7 Add missing '(gash compat)' import.
This was omitted from ffe9fc1f47.

* gash/shell.scm: Use the '(gash compat)' module.
2019-08-02 20:19:52 -04:00
Timothy Sample d9122d7b68 Use 'sh:exit' for 'errexit'.
* gash/shell.scm (errexit): Exit using 'sh:exit'.
* tests/unit/shell.scm: Make sure exit handlers are called on
'errexit'.
2019-08-01 09:12:35 -04:00
Timothy Sample da9a05d500 Do not use 'with-continuation-barrier'.
It turns out that 'with-continuation-barrier' allows delimited
continuations (i.e., prompts) to get through.

* gash/shell.scm (%subshell): Replace 'with-continuation-barrier' with
'dynamic-wind', making sure to preserve exit statuses that were leaked
through before.
* tests/unit/shell.scm (call-with-temporary-directory): Replace
'with-continuation-barrier' with 'dynamic-wind'.
* tests/spec/oil.scm: Enable previously failing tests.
2019-08-01 09:10:38 -04:00
Timothy Sample ffe9fc1f47 Handle 'break' and 'continue' errors.
* gash/built-ins/utils.scm (string->positive-integer): New function.
* gash/built-ins/break.scm (main): Use it to simplify argument
checking; check for too many arguments; and print messages on errors.
* gash/built-ins/continue.scm (main): Ditto.
* gash/shell.scm (sh:exec-let): Throw an error if a special built-in
fails.
* tests/spec/oil.scm: Enable and adjust previously failing tests.
2019-06-14 20:46:57 -04:00
Timothy Sample 38c832a8e2 Add missing copyright headers.
* gash/pattern.scm,
gash/shell.scm,
tests/bootstrap/bash-without-bash.scm,
tests/spec/oil.scm,
tests/unit/config.scm.in: Add missing copyright header.
2019-05-20 18:07:47 -04:00
Timothy Sample 0c57fc9ef9 Move 'textual-ports' under 'compat'.
* gash/textual-ports.scm: Move this...
* gash/compat/textual-ports.scm: ...here.
* Makefile.am, gash/lexer.scm, gash/parser.scm, gash/shell.scm,
tests/unit/shell.scm: Update references.
2019-05-20 18:07:47 -04:00
Timothy Sample df43ca7215 Add support for Guile 2.0.
* configure.ac (GUILE_PKG): Add 2.0.
* gash/textual-ports.scm: New file.
* Makefile.am: Add it.
* gash/lexer.scm, gash/parser.scm, gash/shell.scm: Use it in place of
'(ice-9 textual-ports)'.
* tests/unit/shell.scm: Use it in place of '(ice-9 textual-ports)';
replace '(ice-9 textual-ports)' with '(rnrs io ports)' in sub-scripts;
and add a shim for 'setvbuf'.
2019-05-20 01:18:54 -04:00
Jan Nieuwenhuizen 9f57723fb6 Make 'set -x' print commands.
* gash/shell.scm (sh:exec-let): Respect the 'xtrace' option.
2019-05-20 01:18:22 -04:00
Timothy Sample 1bd92e2893 Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.

Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-05-20 01:17:40 -04:00