Commit Graph

569 Commits

Author SHA1 Message Date
Timothy Sample bbcb78de14 Use built-in compress without an external file.
When the system does not provide a compress executable, we use our
own.  Before, this was done by installing an executable named
'compress' along with Gash.  This commit allows the compressed-port
functions to use our built-in compress without needing an external
executable.

* gash/config.scm.in (exec-internal-compress): New function.
(%compress): Fall back to it on systems without compress.
* gash/guix-utils.scm (filtered-port, filtered-output-port): When the
given command list begins with a procedure, apply it to its arguments
instead of using execl.
2019-01-12 11:42:26 -05:00
Timothy Sample 35444457f8 Remove unused variable from Gash config.
* gash/config.scm.in (%commands): Remove variable.
2019-01-12 11:42:17 -05:00
Timothy Sample 23e53f4e49 Merge branch 'gash'
This commit brings in the entire history of the Gash project.  There
are a few conflicts, which are explained below.

* .dir-locals.el: Combine both files.
* .gitignore: Combine both files.
* COPYING: Use the Geesh version with HTTPS URLs.
* README: Use the Gash README.
* guix.scm: Use the Geesh package definition (the Gash one is
preserved in gash.guix.scm).
2018-12-13 13:42:21 -05:00
Timothy Sample 110167674e Reorganize tests
* tests/bash-without-bash.scm: Move this...
* tests/bootstrap/bash-without-bash.scm: ...here.
* tests/*.scm*: Move these...
* tests/unit: ...into this directory.
* configure.ac: Update paths.
* Makefile.am: Ditto.
* .gitignore: Ditto.
2018-12-12 14:23:09 -05:00
Timothy Sample b67fdc6fbf Remove testing leftovers in the Guix package 2018-12-12 13:11:16 -05:00
Timothy Sample 1cda08dd4a sed: Replace blank regexes with the last regex. 2018-12-11 13:13:46 -05:00
Timothy Sample cb8b2758e0 test: Use script file for sed basename test.
As of this commit, Gash does not process the quotes around the script
properly, and ends up calling sed with no arguments.
2018-12-11 13:13:46 -05:00
Timothy Sample 8c5a9ea96f test: Rename sed dirname test to basename. 2018-12-11 13:13:46 -05:00
Timothy Sample 7aa7a883e0 sed: Add basic support for script files. 2018-12-11 13:13:46 -05:00
Timothy Sample 489f092131 sed: Add quit function. 2018-12-11 13:13:46 -05:00
Timothy Sample 5be7ed331d sed: Support command lists. 2018-12-11 13:13:46 -05:00
Timothy Sample 1302c8bf28 sed: Support single pattern addresses. 2018-12-11 13:13:46 -05:00
Timothy Sample 194c098ab7 sed: Fully parse commands before processing them. 2018-12-11 13:12:45 -05:00
Jan Nieuwenhuizen 0568f73a21 test: failing 100-sed-autoconf-dirname test. 2018-12-09 04:30:32 +01:00
Jan Nieuwenhuizen 8757ab67fb basename: fix /, add autoconf basename, dirname tests. 2018-12-09 04:13:27 +01:00
Jan Nieuwenhuizen f8a4f8aeae doc: Some updates. 2018-12-08 08:36:36 +01:00
Jan Nieuwenhuizen 1d6a0cff99 test: 42-sh-export: New failing test. 2018-12-08 07:55:55 +01:00
Timothy Sample 15ae84bc58 Add test for bootstrapping Bash
* tests/bash-without-bash.scm: New file.
* Makefile.am (check-bootstrap): New target.
2018-12-05 22:21:30 -05:00
Timothy Sample 5287348cdc Add metadata to the Guix package
* guix.scm: Fill out home-page, synopsis, description, and license
fields.
2018-12-05 22:17:41 -05:00
Timothy Sample 88b376c014 Make the Guix package use the current sources
* guix.scm: Use Guile-Git to find the list of source files, and use
those files for the source field of the package.
2018-12-05 22:17:41 -05:00
Timothy Sample acaaa3c322 Use git-version-gen for versioning
* build-aux/git-version-gen: New file.
* .gitignore: Do not ignore it.
* configure.ac: Use it to generate the version string.
* guix.scm: Ditto.
* Makefile.am: Make .tarball-version.
2018-12-05 22:17:41 -05:00
Timothy Sample 177953c4b0 Add support for $$
* geesh/environment.scm (*root-pid*): New variable.
(get-root-pid): New public function.
* geesh/word.scm (parameter-ref): Handle '$'.
2018-12-05 16:23:51 -05:00
Timothy Sample 6b38897dc5 Initialize $PWD properly
* geesh/environment.scm (initial-pwd): New function.
(initial-variables): New function.
(*variables*): Initialize to the result of initial-variables.
2018-12-05 16:22:51 -05:00
Timothy Sample 2db92dd274 Work around missing case expressions
* geesh/eval.scm (exps->thunk): Filter out '#f' expressions.
2018-12-05 16:21:58 -05:00
Timothy Sample 9fd1eb9edf Set search paths explicitly in the geesh script
* configure.ac: Do not treat scripts/geesh as an AC_CONFIG_FILE.
* Makefile.am: Do the substitutions here (at make-time).
* scripts/geesh.in: Update %load-path and %load-compiled-path
explicitly before loading anything.
2018-12-05 16:08:09 -05:00
Timothy Sample 79e5c6eafc Add the trap built-in
* geesh/built-ins/trap.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*special-built-ins*): Add trap.
2018-12-05 16:08:09 -05:00
Timothy Sample 3769dce584 Add the return and exit built-ins
* geesh/built-ins/return.scm: New file.
* geesh/built-ins/exit.scm: New file.
* geesh/Makefile.am: Add them.
* geesh/built-ins.scm (*special-built-ins*): Add return and exit.
2018-12-05 16:08:09 -05:00
Timothy Sample 66e89c1a05 Add return and exit semantics
* geesh/environment.scm (*return-tag*): New variable.
(call-with-return): New public function.
(sh:return): New public function.
(*atexit*): New variable.
(*exiting?*) New variable.
(set-atexit!): New public function.
(sh:exit): New public function.
* geesh/repl.scm (run-repl): Call sh:exit at the end of a script.
* geesh/shell.scm (sh:exec-let): Use call-with-return for functions.
* geesh/built-ins/dot.scm (main): Use call-with-return.
2018-12-05 16:08:09 -05:00
Timothy Sample 2fdbfe2ca4 Add a prefix to break and continue
These names are too common, and it will be even worse with 'exit'
and 'return'.

* geesh/environment.scm (break): Rename this...
(sh:break) ...to this.
(continue): Rename this...
(sh:continue) ...to this.
* geesh/built-ins/break.scm (main): Update call.
* geesh/built-ins/continue.scm (main): Ditto.
2018-12-05 16:08:09 -05:00
Timothy Sample 118750bb79 Handle here-documents everywhere
This commit fixes a problem with the old method of handling
here-documents.  We used to ignore here-documents in many places where
they are valid (e.g., between Boolean operators).  They are now valid
after any 'NEWLINE' token.  To achieve this, the handling logic was
moved out of the parser and into the lexer.  We now use a hook
mechanism to manage the necessary communication between the parser and
lexer.

* geesh/parser.scm (read-here-docs): Return strings instead of tokens.
(make-lexer): Add here-docs-hook as a keyword argument, and call it
after reading here-documents.
(make-parser): Let command-hooks transform commands, and remove
here-document handling rules.
(parse): Handle merging here-documents into commands.
* tests/parser.scm: Add tests for many less-intuitive here-document
locations.
2018-12-05 16:08:09 -05:00
Timothy Sample 8774eec56a Factor out common code from the read-sh functions
* geesh/parser.scm (make-lexer): Remove the read-sh/bracketed and
read-sh/backquoted parameters.
(parse): New function.
(->command-list): New function.
(read-sh/bracketed, read-sh/backquoted, read-sh, read-sh-all):
Simplify by using the new functions.
2018-12-05 16:08:09 -05:00
Timothy Sample c64d16f428 Handle argument special parameters
* geesh/word.scm (parameter-ref): Handle numeric argument parameters
and the argument count parameter ('$#').
2018-12-05 16:08:09 -05:00
Timothy Sample 2543ecd2bb Add the exec built-in
* geesh/built-ins/exec.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*special-built-ins*): Add exec.
2018-12-05 16:08:09 -05:00
Timothy Sample bacbb43650 Add the umask built-in
* geesh/built-ins/umask.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*built-ins*): Add umask.
2018-12-05 16:08:09 -05:00
Timothy Sample a7c5d8cceb Add the shift built-in
* geesh/built-ins/shift.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*special-built-ins*): Add shift.
2018-12-05 16:08:09 -05:00
Timothy Sample bc7e876f6d Fix handling of unknown options in set
* geesh/built-ins/set.scm (main): Continue processing options as new
arguments (i.e., 'set -- ...') after encountering an unknown option.
2018-12-05 16:08:09 -05:00
Timothy Sample 2bcef52895 Allow more character range patterns
* geesh/pattern.scm (ascii-lower-case, ascii-upper-case, asii-digits):
Remove variables.
(character-range): New function.
(parse-matching-bracket-expression): Use it to allow any character
range contained in one of the ASCII uppercase, ASCII lowercase, or
ASCII digits character sets.
2018-12-05 16:08:09 -05:00
Timothy Sample c1f8a870ed Add the dot and eval built-ins
* geesh/built-ins/utils.scm (get-evaluator): New public function.
* geesh/built-ins/dot.scm: New file.
* geesh/built-ins/eval.scm: New file.
* geesh/Makefile.am: Add them.
* geesh/built-ins.scm (*special-built-ins*): Add dot and eval.
2018-12-05 16:08:09 -05:00
Timothy Sample 6a68c73a7b Enable a test from the redirect spec. tests
* tests/spec/oil.scm: Enable a redirect test that requires errexit.
2018-12-05 16:08:09 -05:00
Timothy Sample 0ec3ed02a0 Enable the errexit specification test
* tests/spec/Makefile.am (TESTS): Add errexit.
* tests/spec/oil.scm: Filter and modify five of its tests.
2018-12-05 16:08:09 -05:00
Timothy Sample 50328c8c66 Respect the errexit option
* geesh/shell.scm (ignore-errexit?): New parameter.
(without-errexit): New function.
(errexit): New function.
(sh:exec-let, sh:set-redirects, sh:with-redirects, sh:subshell,
sh:substitute-command, sh:pipeline, sh:and, sh:or, sh:not, sh:while,
sh:cond): Use it to exit on nonzero status.
2018-12-05 16:08:09 -05:00
Timothy Sample af75931948 Process options passed to the set built-in
* geesh/built-ins/set.scm (option?): New function.
(option-letter?): New function.
(set-option!): New function.
(main): Set or print options as specified by the given arguments.
* tests/spec/oil.scm: Filter out a redirect test that was only passing
because set did not work.
2018-12-05 16:08:09 -05:00
Timothy Sample c83dbcbdc8 Add options to the environment
* geesh/environment.scm (*options*): New variable.
(getopt): New public function.
(setopt!): New public function.
(*option-names*): New public variable.
(*option-letters*): New public variable.
2018-12-05 16:08:09 -05:00
Timothy Sample b4a6350887 Exit subshells with the current status
* geesh/shell.scm (%subshell): Use with-continuation-barrier and
primitive-exit to make sure the child process exits with its status.
2018-12-05 16:08:09 -05:00
Timothy Sample 77f3113fd0 Set status to 0 when all sh-cond tests fail
* geesh/shell.scm (sh:cond): If no body thunk is called, set the
status to 0.
2018-12-05 16:08:09 -05:00
Timothy Sample 8c061471d3 Handle command not found with status 127
* geesh/shell.scm (sh:exec-let): Print a message and set the status to
127 when path search fails.
* tests/shell.scm: Update test.
2018-12-05 16:08:09 -05:00
Timothy Sample 2c1dd2d67e Add the colon built-in
* geesh/built-ins/colon.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*special-built-ins*): Add colon.
2018-12-05 16:08:09 -05:00
Timothy Sample 36e4811d22 Pass options through when running spec. tests
tests/spec/Makefile.am (oil/bin/geesh): Pass options through.
2018-12-05 16:08:09 -05:00
Timothy Sample a1bd8d0681 Add basic option processing to the main script
* geesh/repl.scm (run-repl): Add optional port parameter.
* scripts/geesh.in: Add '--command' and '--stdin' flags, and if
neither flag is provided, treat the first argument as a file to
interpret.
2018-12-05 16:08:09 -05:00
Timothy Sample 271301e77d Add the cd and pwd built-ins
* geesh/built-ins/cd.scm: New file.
* geesh/built-ins/pwd.scm: New file.
* Makefile.am: Add them.
* geesh/built-ins.scm (*built-ins*): Add cd and pwd.
2018-12-05 16:08:09 -05:00