Commit Graph

562 Commits

Author SHA1 Message Date
Timothy Sample 589b92e430 Remove unneeded files.
* HACKING,
TODO,
bin/builtin.in,
sh.bnf,
todo/*: Delete files.
2019-05-20 01:18:54 -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
Timothy Sample 9af8bb2832 Remove 'setvbuf' in string port redirect test.
This was only relevant to an older implementation of redirects, and
does not make much sense for us now.

* tests/unit/shell.scm (Redirects here-document to standard input):
Remove call to 'setvbuf'.
2019-05-20 01:18:54 -04:00
Timothy Sample 5b236ceef3 Structure 'echo' like all the other built-ins.
* gash/built-ins/echo.scm (echo): Rename this...
(main): ...to this, and do not export it.
* gash/built-ins.scm: Reference the 'main' function of the 'echo'
module using '@@'.
2019-05-20 01:18:54 -04:00
Timothy Sample 10400ed2ad Remove PEG modules and the PEG-based parser.
* gash/grammar.scm,
gash/peg.scm,
gash/peg/cache.scm,
gash/peg/codegen.scm,
gash/peg/simplify-tree.scm,
gash/peg/string-peg.scm,
gash/peg/using-parsers.scm: Delete files.
Makefile.am: Remove them.
2019-05-20 01:18:54 -04:00
Timothy Sample 0b73a0e70f Remove 'gash.guix.scm'.
* gash.guix.scm: Delete file.
2019-05-20 01:18:54 -04:00
Timothy Sample 874d165b11 Remove the unused 'geesh' module.
* gash/geesh.scm: Delete file.
* Makefile.am: Do not compile it.
* gash/gash.scm (%geesh-parser?): Remove unused variable.
(parse, parse-string, file-to-ast): Remove unused procedures.
2019-05-20 01:18:54 -04:00
Jan Nieuwenhuizen 5b74c6426a echo: Implement escapes.
* gash/built-ins/echo.scm (escape->control): New function.
(echo): Support '-e' and '-E' options even when clumped.
* Makefile.am (XFAIL_TESTS): Remove tests/20-pipe-sed.sh.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:18:48 -04:00
Jan Nieuwenhuizen 1cd6f963ea Allow setting the status with a Boolean.
* gash/environment.scm (set-status!): Allow numerical or boolean input.
2019-05-20 01:18:48 -04:00
Jan Nieuwenhuizen 18aefdda18 tests: Add 100-test-false.sh.
* tests/100-test-false.sh: New file.
* Makefile.am (FULL_TESTS): Add it.
2019-05-20 01:18:48 -04:00
Jan Nieuwenhuizen 06099ddead tests: Add 43-trap-subshell.sh.
* tests/43-trap-subshell.sh: New file.
* tests/43-trap-subshell.stdout: New file.
* Makefile.am (FULL_TESTS): Add tests/43-trap-subshell.sh.
2019-05-20 01:18:48 -04:00
Jan Nieuwenhuizen bbb74ab958 Delete merge leftover.
* check.sh: Delete file.
2019-05-20 01:18:48 -04:00
Jan Nieuwenhuizen 7640a09382 Support redirects with empty commands.
* gash/eval.scm (exp->thunk): Return 'noop' if 'exp' is '#f'.
* tests/50-redirect-clobber.sh: New file.
* tests/50-redirect-clobber.stdout: New file.
* Makefile.am (FULL_TESTS): Add tests/50-redirect-clobber.sh.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:18:36 -04:00
Jan Nieuwenhuizen 6808c941f1 Respect '--parse' flag for files and non-TTY inputs.
* gash/gash.scm (main): Include 'parse?' in all calls to 'run-repl'.
2019-05-20 01:18:36 -04:00
Jan Nieuwenhuizen 13f43973f5 Do not export unset variables.
* gash/environment.scm (get-environ): Filter out unset variables.
* tests/42-sh-export-new.sh: New file.
* tests/42-sh-export-new.stdout: New file.
* Makefile.am (FULL_TESTS): Add tests/42-sh-export-new.sh.
(XFAIL_TESTS): Remove tests/42-export-new.sh and tests/42-sh-export.sh.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:18:22 -04:00
Jan Nieuwenhuizen 25597a4bec set: Support clumped flags, e.g. set -eux.
* gash/built-ins/set.scm (main): Support clumped flags.
2019-05-20 01:18:22 -04:00
Timothy Sample 50473ac9d4 Add copyright sign to headers.
* gash/built-ins/*, gash/environment.scm, gash/eval.scm,
gash/lexer.scm, gash/parser.scm, gash/repl.scm, gash/word.scm,
tests/unit/*, tools/coverage.in: Add copyright sign to headers.
2019-05-20 01:18:22 -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
Jan Nieuwenhuizen 05f3880419 Remove accidentally committed files.
* 07-variable-or-slash.stdout: Delete file.
* 70-slash-string-slash.stdout: Delete file.
2019-05-20 01:18:22 -04:00
Jan Nieuwenhuizen 2e4e078975 Fix some environment-dependent tests.
* gash/environment.scm (initial-variables): Add 'SHELL' and 'SHELLOPTS'.
* tests/100-cd.sh, tests/100-cd.stdout: Use '/tmp' instead of '/bin'.
* tests/50-redirect-in-out.sh, tests/50-redirect-space.sh,
tests/50-redirect.sh: Use '/tmp' and PID for temporary files.
* tests/50-redirect-sed.sh: Make sure 'DESTDIR' is unset and use
'/bin/GASH' in place of '/bin/gash'.
* tests/50-redirect-sed.stdout, tests/data/diff.scm: Use '/bin/GASH' in
place of '/bin/gash'.
* Makefile.am (FULL_TESTS): Add tests/50-redirect-sed.sh,
tests/50-redirect-space.sh, and tests/100-cd.sh; remove
tests/50-redirect-merge.sh.
(BROKEN_TESTS): Remove tests/10-if-redirect.sh,
tests/50-redirect-sed.sh, tests/50-redirect-space.sh, and
tests/100-cd.sh; add tests/50-redirect-merge.sh.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:18:07 -04:00
Jan Nieuwenhuizen 56610b0669 Add export test.
* tests/42-export-new.sh: New file.
* tests/42-export-new.stdout: New file.
* Makefile.am (FULL_TESTS, XFAIL_TESTS): Add 42-export-new.sh.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:17:57 -04:00
Timothy Sample e87f351f3e Add missing copyright headers.
* gash/gash.scm, gash/grammar.scm, gash/io.scm, gash/job.scm,
gash/pipe.scm, gash/script.scm: Add missing copyright header.

Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-05-20 01:17:48 -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
Timothy Sample f387269c0b Only use readline for TTYs.
* gash/gash.scm: Hide the readline interface behind a check for
'isatty?', and default to just running the plain REPL.
2019-05-20 01:17:40 -04:00
Jan Nieuwenhuizen 7fcfe66407 Add the 'command' built-in.
* geesh/built-ins/command.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*built-ins*): Add 'command'.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:17:30 -04:00
Jan Nieuwenhuizen 57e8e3bd64 Add the 'type' built-in.
* geesh/built-ins/type.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*built-ins*): Add 'type'.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:17:22 -04:00
Timothy Sample f4dd0feb77 Do not clobber status before 'cond' expressions.
This spurious status reset must have been an attempt to make sure that
when no branch is taken, the status ends up as zero.  It is not
necessary and causes problems when trying to branch based on the value
of '$?'.

* geesh/shell.scm (sh:cond): Remove spurious 'set-status!'.
2019-05-20 01:17:22 -04:00
Timothy Sample ae769985be Reset signal and exit handlers in subshells.
* geesh/shell.scm (%subshell): In the child process, restore all
signal handlers to their original actions and unset the current
'atexit' handler.
2019-05-20 01:17:22 -04:00
Timothy Sample c169a90753 Use default value when unpacking variable vector.
* geesh/environment.scm (getvar): Use 'dflt' when we have a vector but
'value' is '#f'.
2019-05-20 01:17:22 -04:00
Timothy Sample 64aa779315 lexer: Do not let comments delimit words.
The '#' character only introduces a comment if it occurs where a word
would begin.  If it occurs within a word, it is not treated specially.

* geesh/lexer.scm (get-word): Do not treat '#' specially.
2019-05-20 01:17:22 -04:00
Timothy Sample 4d1e0c96a4 shell: Make 'continue' work in while loops.
* geesh/shell.scm (sh:while): Use 'call-with-continue' when invoking
the body thunk.
2019-05-20 01:17:22 -04:00
Timothy Sample 0dc3f63cad Handle '$LINENO'.
* geesh/lexer.scm (get-parameter-expansion): Include the current line
number with the variable name if it is 'LINENO'.
(call-with-metered-input-port): Set the line number of the soft port.
* geesh/word.scm (parameter-ref): Unpack the included line number when
the parameter name is 'LINENO'.
2019-05-20 01:17:22 -04:00
Jan Nieuwenhuizen c6a3d13c69 word: Add context to "not implemented" errors.
* geesh/word.scm (word->qword): Include the word form in "not
implemented" error messages.
2019-05-20 01:17:22 -04:00
Jan Nieuwenhuizen 2d99ab62d0 Update AUTHORS.
* AUTHORS: Add Timothy Sample as a main author; remove files that no
longer exist.
2019-05-20 01:17:22 -04:00
Jan Nieuwenhuizen cf5611f6d4 Replace geesh script with gash.
* geesh/repl.scm (run-repl): Add optional parse? parameter.
* gash/gash.scm (main): Rewrite to use Geesh parser and evaluator.
* scripts/geesh.in: Remove.
* Makefile.am: Remove scripts/geesh; adjust XFAIL_TESTS.
* .gitignore: Update.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2019-05-20 01:17:14 -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 42f9fb2671 Stabilize test suite.
* test.sh: Increase test timeout from 1 to 10.
* Makefile.am (FULL_TESTS): Move tests/10-if-redirect.sh,
tests/50-redirect-space.sh, tests/50-redirect-sed.sh, and
tests/100-cd.sh from here...
(BROKEN_TESTS): ...to here.
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 7e8caba055 Build Gash with Autotools.
This commit allows most of Gash to be built with Autotools.  It also
removes some of the Gash build scripts.

* configure.ac: Add checks for compress, gzip, bzip2, and xz;
configure gash/config.scm.
* Makefile.am: Add Gash modules and the 'gash' script.
* scripts/gash.in: Rename 'guile_site_dir' to 'MODDIR' and
'guile_site_ccache_dir' to 'GODIR'.
* configure: Delete file.
* makefile: Delete file.
* build-aux/build-guile.sh: Delete file.
* build-aux/pre-inst-env.in: Delete file.
* build-aux/trace.sh: Delete file.
* .gitignore: Add configure; remove exceptions for the deleted
build-aux files.
2019-05-16 10:49:16 -04:00
Timothy Sample c5e5a34fc0 Move bin/gash to scripts.
* bin/gash.in: Move this...
* scripts/gash.in: ...here.
* configure, build-aux/build-guile.sh, makefile,
  check.sh, test.sh, .gitignore: Update references.
2019-01-12 11:42:35 -05:00
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