Commit Graph

77 Commits

Author SHA1 Message Date
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
Timothy Sample 171796317f Remove external commands.
* gash/bournish-commands.scm, gash/commands/*, gash/compress.scm,
gash/guix-utils.scm, gash/lzw.scm, gash/ustar.scm: Delete files.
* gash/builtins.scm, gash/gash.scm, gash/script.scm: Remove references
to deleted modules.
* tests/100-basename-*, tests/100-dirname-*, tests/100-sed-*,
tests/100-tar-*, tests/100-tr-*: Delete files.
* Makefile.am: Remove deleted modules and tests.
2019-05-16 10:49:38 -04:00
Timothy Sample 117a33d18e Use Automake to run Gash tests.
* Makefile.am: Add Gash tests and use test.sh as the log compiler.
* test.sh: Use TEST_SHELL instead of SHELL to parameterize which shell
is being tested.
* tests/06-command-compound-word.sh: Adjust this test so that it works
even if the srcdir variable is set.
* .gitignore: Add tests/*.trs
2019-05-16 10:49:38 -04:00
Timothy Sample 3584866b73 Remove special characters from test names.
* tests/01-script-$0.sh: Rename this...
* tests/01-script-arg-0.sh: ...to this.
* tests/01-script-$#.sh: Rename this...
* tests/01-script-arg-length.sh: ...to this.
* tests/01-script-$#.stdout: Rename this...
* tests/01-script-arg-length.stdout: ...to this.
* tests/01-script-$@.sh: Rename this...
* tests/01-script-arg-list.sh: ...to this.
* tests/01-script-$@.stdout: Rename this...
* tests/01-script-arg-list.stdout: ...to this.
* check.sh: Update test names.
2019-05-16 10:49:38 -04:00
Timothy Sample fe7a322d4e Move test/* to tests.
* test/*: Move these...
* tests: ...to this directory.
* check.sh, test.sh, .gitignore: Update references.
2019-05-16 10:49:38 -04:00
Timothy Sample c5f2f56268 Move test data to tests/data.
* test/data/*: Move these...
* tests/data: ...to this directory.
* test/20-pipe-sed-cat.sh, test/20-pipe-sed-cat.stdout,
test/20-pipe-sed.sh, test/20-pipe-sed.stdout, test/41-dot.sh,
test/42-sh-export.sh, test/42-sh.sh, test/50-redirect-in-out.sh,
test/50-redirect-in.sh, test/50-redirect-sed.sh, test/60-subst.sh,
test/100-sed-autoconf-basename.sh, test/100-sed-file.sh,
test/100-sed-fooRbar.sh, test/100-tar-Z-old.sh,
test/100-tar-Z-old.stdout, test/100-tar-Z-pipe.sh,
test/100-tar-Z-pipe.stdout, test/100-tar-Z.sh, test/100-tar-Z.stdout,
test/100-tar-ro.sh, test/100-tar.sh, test/100-tar.stdout,
test/100-tr.sh: Update references.
2019-05-16 10:49:38 -04: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 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 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 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 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 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 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 4ef6907851 Globalize the environment module
Instead of passing around references to the environment, just treat it
as a global.  The old way was just the remains of an idea to make the
environment immutable and keep the interpreter from manipulating any
global state.  By making everything global and mutable, we will have
less impedance mismatch with POSIX going forward.

The following changelog is only a sketch, since nearly every function
has changed.

* geesh/environment.scm: Replace this module with one that treats the
environment as a global resource.
* tests/environment.scm: Delete file.
* Makefile.am: Remove it from the list of tests.
* geesh/shell.scm, geesh/eval.scm, geesh/repl.scm, geesh/word.scm,
geesh/built-ins/break.scm, geesh/built-ins/continue.scm,
geesh/built-ins/echo.scm, geesh/built-ins/export.scm,
geesh/built-ins/false.scm, geesh/built-ins/read.scm,
geesh/built-ins/readonly.scm, geesh/built-ins/set.scm,
geesh/built-ins/true.scm, geesh/built-ins/unset.scm: Remove 'env'
parameters and use the new environment module.
* .dir-locals.el: Update indentation of functions that no longer take
an 'env' parameter and add with-arguments, with-environ, and
with-variables from the new environment module.
* tests/shell.scm, tests/word.scm: Update environment creation and
manipulation in tests.
2018-12-05 16:08:09 -05:00
Timothy Sample dd64f22361 Enable 'loop' specification test
* tests/spec/Makefile.am (TESTS): Add 'loop'.
* tests/spec/oil.scm: Remove one test and patch four others.
2018-12-05 16:08:09 -05:00
Timothy Sample a5a1f85aa7 Enable 'case_' specification test
* tests/spec/Makefile.am (TESTS): Add 'case_'.
* tests/spec/oil.scm: Filter out two Bash-specific tests.
2018-12-05 16:08:09 -05:00
Timothy Sample e1ab2ccd94 Add pattern module
* geesh/pattern.scm: New file.
* tests/pattern.scm: New file.
* Makefile.am: Add them.
2018-12-05 16:08:09 -05:00
Timothy Sample da71aed3e3 Enable 'var-sub' specification test
* tests/spec/Makefile.am (TESTS): Add 'var-sub'.
* tests/spec/oil.scm: Patch three of its tests.
2018-12-05 16:08:09 -05:00
Timothy Sample 420ade9658 Enable 'quote' specification test
* tests/spec/Makefile.am (TESTS): Add 'quote'.
* tests/spec/oil.scm: Patch two of its tests and filter out six
others.
2018-12-05 16:08:09 -05:00
Timothy Sample 06a0b5f885 Set PYTHONIOENCODING before running tests
* tests/spec/check-spec: Set PYTHONIOENCODING to 'utf-8' before
running tests.
2018-12-05 16:08:09 -05:00
Timothy Sample f33669e636 Remove the BusyBox shell from specification tests
* tests/spec/oil.scm: Patch the test suite script to prevent it from
trying to run the BusyBox shell.
2018-12-05 16:08:09 -05:00
Timothy Sample 6805fc37b4 Patch and enable some specification tests
* tests/spec/oil.scm: Patch and enable five tests that were only
failing due to trivialities.
2018-12-05 16:08:09 -05:00
Timothy Sample 8fe509359d Add specification test patching
Sometimes we need to make minor changes to the tests to make them work
for us.  This patch enables doing search and replace on a test-by-test
basis.

* tests/spec/oil.scm: Allow for tests to be modified.
2018-12-05 16:08:09 -05:00
Timothy Sample ab30ebd14e Enable 'redirect' specification test
* tests/spec/Makefile.am (TESTS): Add 'redirect'.
* tests/spec/oil.scm: Filter out nine tests from it.
2018-12-05 16:08:09 -05:00
Timothy Sample 4cff559d1f Fix another shebang in Oil build script
* tests/spec/oil.scm: Add 'spec/bin/printenv.py' to the list of files
that get passed to 'patch-shebang'.
2018-12-05 16:08:09 -05:00
Timothy Sample 0ae52599c4 Preserve input and error ports in substitutions
This was simply a mistake.

* geesh/shell.scm (sh:substitute-command): Leave 'current-input-port'
and 'current-error-port' alone.
* tests/shell.scm: Remove tests that check that input and error gets
ignored during substitutions.
2018-12-05 16:08:09 -05:00
Timothy Sample 9dbf64d740 Enable 'word-split' specification test
* tests/spec/Makefile.am (TESTS): Add 'word-split'.
* tests/spec/oil.scm: Filter out four tests from it that we cannot
support yet.
2018-12-05 16:08:09 -05:00
Timothy Sample f448a57a27 Add filtering for specification tests
* tests/spec/oil.scm: Add code to filter out specific test cases from
a test file.
2018-12-05 16:08:09 -05:00
Timothy Sample 4b7d2404f3 Fix handling of non-whitespace IFS separators
* geesh/word.scm (string-tokenize*): New function.
(split-fields): Use it to handle non-whitespace IFS separators.
* tests/word.scm: Add tests.
2018-12-05 16:08:09 -05:00
Timothy Sample 3e6d7830a9 Fix splitting nested words
* geesh/word.scm (split-fields): Move handling of list words into
'wedge-apart' so that they get handled in recursive calls.
* tests/word.scm: Add a test for this.
2018-12-05 16:08:01 -05:00
Timothy Sample 765e91eb88 Elide unquoted empty and unset variables
* geesh/word.scm (split-fields): Make an empty string yield zero
fields (an empty list).
* tests/word.scm: Update tests and add tests to make sure that quoted
empty strings are preserved.
2018-12-05 16:06:14 -05:00
Timothy Sample f84b6235db Add Oil shell specification tests
tests/spec/oil.scm: New file.
tests/spec/check-spec: New file.
tests/spec/Makefile.am: New file.
configure.ac: Add the new Makefile.
Makefile.am (check-spec): New rule for running Oil shell
specification tests.
(clean-local): New rule that tells Automake how to clean up the
specification tests.
.gitignore: Add tests/spec/oil and tests/spec/oil-link.
2018-12-05 16:06:14 -05:00
Timothy Sample 37f4ce6ea8 Add pipeline semantics
* geesh/shell.scm (swap-and-shift-pairs): New function.
(make-pipes): New function.
(plumb): New function.
(sh:pipeline): New public function.
* tests/shell.scm: Test it.
2018-12-03 20:09:55 -05:00
Timothy Sample 553b8f2b96 Use ports for redirects
Before, we were using raw file descriptors.  This worked okay, but
there was interference caused by port buffering.  Doing everything at
the port level avoids this problem, and has the added benefit of
allowing one to use the 'current-*-port' parameters with the shell
module (in a limited way, but there is room for improvement).

* geesh/shell.scm (*fd-count*): New variable.
(fd->current-port): New function.
(install-current-ports!): New function.
(exec-utility): Use it to set up file descriptors.
(save-and-install-redirect!): Rename this...
(save-and-set-redirect): ...to this and modify the current port
parameters instead of raw file descriptors.
(restore-saved-fdes!): Rename this...
(restore-saved-port): ...to this.
(sh:with-redirects): Adjust to use the renamed functions.
(sh:substitute-command): Parameterize the current ports directly
instead of using redirects.
* tests/shell.scm: Add tests to check if port buffers cause problems.
2018-12-03 20:07:53 -05:00
Timothy Sample 6b6ca11bce Add command substitution semantics
* geesh/shell.scm (%subshell): New function factored out from 'subshell'.
(subshell): Use it.
(substitute-command): New public function.
* tests/shell.scm: Test it.
* .dir-locals.el: Indent it nicely.
2018-12-03 20:06:47 -05:00
Timothy Sample 8739cafad9 Add subshell semantics
* geesh/shell.scm (subshell): New public function.
* tests/shell.scm: Test it.
* .dir-locals.el: Indent it nicely.
2018-11-28 23:07:03 -05:00
Timothy Sample e6f732ada9 Add redirect semantics
* geesh/shell.scm (save-and-install-redirect!): New function.
(restore-saved-fdes!): New function.
(with-redirects): New public function.
* tests/shell.scm: Test it.
* .dir-locals.el: Indent it nicely.
2018-11-28 23:07:03 -05:00
Timothy Sample 737ed6a1b7 Add function for reading an 'environ'
* geesh/environment.scm (environ->alist): New function.
* tests/environment.scm: Test it.
2018-11-28 23:07:03 -05:00
Timothy Sample 549d1e7867 Remove REPL unit tests
In order to test the REPL in isolation, we would have to mock out the
parser and interpreter.  This is possible, but too much work for the
benefit (at least for now).

* tests/repl.scm: Deleted.
* Makefile.am: Remove it.
2018-11-28 23:07:03 -05:00
Timothy Sample e1f139b841 Add support for built-ins, starting with 'echo'
* geesh/built-ins/echo.scm: New file.
* geesh/built-ins.scm: New file.
* Makefile.scm: Add them.
* geesh/shell.scm (exec-let): Include built-ins in command search.
* tests/shell.scm: Add a test for this.
2018-11-28 23:07:03 -05:00
Timothy Sample 7cc94e88e1 Add PATH searching
* geesh/shell.scm (slashless?) New function.
(split-search-path): New function.
(find-utility): New function.
(exec-let): Use them to search PATH for a utility when appropriate.
(exec): Update doc string.
* tests/shell.scm: Test it.
2018-11-28 23:07:03 -05:00
Timothy Sample b9ec924bbe Add shell module
* geesh/shell.scm: New file.
* tests/shell.scm: New file.
* Makefile.am: Add them.
* tests/config.scm.in: New file.
* configure.ac: Add it.
* .gitignore: Add its generated form.
* .dir-locals.el: Add indentation rule for 'make-script'.
2018-11-28 23:07:03 -05:00
Timothy Sample cfb2b5b99b Add function for creating an 'environ'
* geesh/environment.scm (environment->environ): New function.
* tests/environment.scm: Test it.
2018-11-28 23:07:03 -05:00
Timothy Sample 99378697e2 Add missing '(test-end)' to environment tests
* tests/environment.scm: Add '(test-end)'.
2018-11-28 23:07:03 -05:00
Timothy Sample 9d834d0767 Fix parsing of for loops
* geesh/parser.scm (make-parser): When parsing for loops, make all
word-lists actual lists, and make an empty word-list with the 'in'
keyword yield an empty list rather than a reference to '$@'.
* tests/parser.scm: Update tests.
2018-11-28 23:04:30 -05:00
Timothy Sample 48e122c42f Fix AST for redirects and assignments
This should have been in 2b05199562, but
it was overlooked.

* geesh/parser.scm (make-parser): Splice in arguments in the redirect
case (to be consistent with the non-redirect case).
* tests/parser.scm: Add a test for this.
2018-11-28 22:09:34 -05:00
Timothy Sample 73414716bb Fix lexing of empty double quotes
* geesh/lexer.scm (get-double-quotation): Handle empty quotation.
* tests/lexer.scm: Add a test for this and for empty single
quotes (which already worked correctly).
2018-11-09 16:22:11 -05:00
Timothy Sample ff14ea0097 Rename '<sh-define>' to '<sh-defun>' and simplify
This change is already in the syntax document.

* geesh/parser.scm (make-parser): Rename '<sh-define>' to '<sh-defun>'
and use the function name directly instead of making it a singleton
list.
* tests/parser.scm: Update tests.
* .dir-locals.el: Update indentation.
2018-11-02 14:35:34 -04:00
Timothy Sample 2d61e91b27 Flatten AST form for pipelines
* geesh/parser.scm (make-parser): Splice in commands to keep
'<sh-pipeline>' flat.
* tests/parser.scm: Adjust and add tests accordingly.
2018-07-19 01:28:43 -04:00