Commit Graph

687 Commits

Author SHA1 Message Date
Timothy Sample 864e51250b lexer: Avoid 'fold-right'.
* gash/lexer.scm (join-contiguous-strings): Use 'fold' and 'reverse'
instead of 'fold-right'.
2023-02-08 14:29:54 -06:00
Timothy Sample cfb4da73d0 lexer: Do not overflow the Mes character buffer.
* gash/lexer.scm (get-token->get-lexical-token): Allow arbitrary
procedure arguments that start with a 'port' argument.
(get-word-lexical-token): Accept a 'start' argument that and push it
onto the soft port character buffer.
(get-token): Use it to avoid ungetting more than one character on a
raw file port.
2023-02-08 14:29:54 -06:00
Timothy Sample ddb5c7ef36 compat: Fix parameter setting.
* gash/compat.scm [mes] (make-parameter): Add missing argument to
'fluid-set!' invocation.
2023-02-08 14:29:54 -06:00
Timothy Sample 00c794c9a6 compat: Add a 'usleep' shim for Mes.
* gash/compat.scm [mes] (usleep): New procedure.
2023-02-08 14:29:54 -06:00
Timothy Sample 88dfac30c3 built-ins: read: Port to Mes.
* gash/built-ins/read.scm (define-module): Import SRFI 14.
(right-pad): New procedure.
(main): Use it in place of a 'circular-list' trick.
2023-02-08 14:29:54 -06:00
Timothy Sample 7d713e0435 built-ins: eval: Import '(gash compat)'.
* gash/built-ins/eval.scm (define-module): Import '(gash compat)'.
2023-02-08 14:29:54 -06:00
Timothy Sample 13e60e1952 environment: Simplify a 'match' clause for Mes.
* gash/environment.scm (get-environ): Simplify the 'match' clause
for finding exported variables.
2023-02-08 14:29:54 -06:00
Timothy Sample 9b53a6b25b Workaround Mes' non-parameter standard ports.
* gash/environment.scm (current-0-port): New procedure.
(current-1-port): New procedure.
(current-2-port): New procedure.
(fd->current-port): Use them instead of the standard parameters.
* gash/shell.scm (sh:with-redirects): Do not use 'parameterize' with
the non-parameter ports.
(plumb): Likewise.
2023-02-08 14:29:44 -06:00
Timothy Sample 4b1aa935de word: Use sort with 'scandir' on Mes.
* gash/word.scm [mes]: Monkey patch 'scandir' to add sorting.
2023-02-08 14:29:13 -06:00
Timothy Sample 6c67d7b23d compat: More shims for Mes.
* gash/compat.scm [mes] (call-with-input-file): New procedure.
[mes] (exact?): New procedure.
[mes] (set-program-arguments): New procedure.
[mes] (open-file): New procedure.
[mes] (false-if-exception): New syntax.
[mes] (hex-digits): New variable.
[mes] (char->hex-string): New procedure.
[mes] (make-random-file-name): New procedure.
[mes] (tmpfile): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample 4c04f1faa3 compat: Add 'sort' for Mes.
* gash/compat.scm [mes] (sort): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample a087816b90 compat: Add 'get-string-all' for Mes.
* gash/compat/textual-ports.scm [mes] (get-string-all): New
procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample c6d39caecc pattern: Adjust for Mes.
* gash/pattern.scm (substring->list): New procedure.
(character-range): Use it.
2023-02-08 14:29:13 -06:00
Timothy Sample b973b21cc7 tests: eval: Tweak a hexadecimal constant test.
* tests/unit/eval.scm: Switch the constant used in the hexadecimal
constant test to one that includes a letter digit.
2023-02-08 14:29:13 -06:00
Timothy Sample 3697ed5bf1 tests: Print errors if the status is wrong.
* tests/run-test-suite.in (run-test): If the test exits with an
unexpected status, print everything written to standard error to
make debugging easier.
2023-02-08 14:29:13 -06:00
Timothy Sample 1c398c263c tests: Check for abnormal exits.
* tests/run-test-suite.in (run-test): Check if the test exited
abnormally.
2023-02-08 14:29:13 -06:00
Timothy Sample b643ac2355 compat: New 'read-line' shim.
* gash/compat/rdelim.scm: New file.
* Makefile.am (SOURCES): Add it.
* gash/built-ins/read.scm: Use it.
* gash/lexer.scm: Likewise.
* gash/readline.scm: Likewise.
* gash/repl.scm: Likewise.
2023-02-08 14:29:13 -06:00
Timothy Sample 469cdb60fc compat: Add 'string-for-each' for Mes.
* gash/compat.scm [mes] (string-for-each): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample 1b5ba1e9ec arithmetic: Port to Mes.
* gash/arithmetic.scm (define-module): Import SRFI 14.
* gash/eval.scm (eval-arithmetic): New procedure.
(word->qword): Use it to abstract away the differences in 'eval'
between Guile and Mes.
2023-02-08 14:29:13 -06:00
Timothy Sample 2b44788598 pattern: Workaround Mes optargs difference.
* gash/pattern.scm (pattern-match?): Remove optional arguments.
2023-02-08 14:29:13 -06:00
Timothy Sample 7fb21c1549 pattern: Do not use record matching.
Mes does not support it, and also the code is cleaner without it!

* gash/pattern.scm (pattern-match?, pattern-drop)
(pattern-drop-right): Avoid record matching.
2023-02-08 14:29:13 -06:00
Timothy Sample 10ee7d286e compat: Add prompts for Mes.
* gash/compat.scm [mes] (make-prompt-tag): Return a fluid.
[mes] (abort-to-prompt): New procedure.
[mes] (call-with-prompt): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample 52e03d4d22 compat: Add 'exact-integer?' for Mes.
* gash/compat.scm [mes] (exact-integer?): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample f5a4619c69 compat: Add exit codes for Mes.
* gash/compat.scm [mes] (EXIT_SUCCESS): New variable.
[mes] (EXIT_FAILURE): New variable.
2023-02-08 14:29:13 -06:00
Timothy Sample d088464510 compat: Add 'call-with-input-string' for Mes.
* gash/compat.scm [mes] (call-with-input-string): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample efe0522d06 compat: Add 'thunk?' for Mes.
* gash/compat.scm [mes] (thunk?): New procedure.
2023-02-08 14:29:13 -06:00
Timothy Sample a584a5bd9c compat: Add Mes shims for the 'eval' module.
* gash/compat.scm [mes] (string-concatenate-reverse): New procedure.
[mes] (char-pred): New procedure.
[mes] (string-any): New procedure.
[mes] (string-every): Allow character sets and characters as the
predicated (using 'char-pred').
2023-02-08 14:29:13 -06:00
Timothy Sample 4f3ae9e083 built-ins: echo: Import '(gash compat)'.
* gash/built-ins/echo.scm: Import '(gash compat)'.
2023-02-08 14:29:13 -06:00
Timothy Sample 309f9a8893 compat: Add shims for the 'shell' module.
* gash/compat.scm [mes] (X_OK): New variable.
[mes] (program-arguments): New procedure.
[mes] (delete-duplicates!): New procedure.
[mes] (flush-all-ports): New procedure.
[mes] (file-port?): New procedure.
[mes] (input-port?): New procedure.
[mes] (output-port?): New procedure.
[mes] (dup): Redefine to support an optional 'new' argument.
2023-02-08 14:29:13 -06:00
Timothy Sample 83f3369603 compat: srfi-43: Adjust for Mes.
* gash/compat/srfi-43.scm (shared-shims): New macro.
[if-guile-version-below (2 0 10)]: Use it.
[mes]: Likewise.
2023-02-08 14:29:13 -06:00
Timothy Sample ca3b6d354c built-ins: utils: Import SRFI 14 for Mes.
* gash/built-ins/utils.scm: Import '(srfi srfi-14)'.
2023-02-08 14:29:13 -06:00
Timothy Sample 26cf4933c9 config: Tell Mes not to complain about '%version'.
* gash/config.scm.in [mes]: Mark '%version' as a replacement.
2023-02-08 14:29:13 -06:00
Timothy Sample 386d12aa21 wip! environment: Port to Mes.
TODO: Implement 'canonicalize-path'.

* gash/compat.scm [mes] (make-prompt-tag): New procedure.
[mes] (canonicalize-path): New procedure.
* gash/compat/hash-table.scm (shared-shims): New macro.
[if-guile-version-below (2 0 10)]: Use it.
[mes]: Likewise.
* gash/environment.scm: Import '(gash compat)' and '(srfi srfi-14)'.
2023-02-08 14:29:13 -06:00
Timothy Sample 0c554b6b13 parser: Port to Mes.
* gash/compat.scm [mes] (the-eof-object): New variable.
[mes] (noop): New procedure.
* gash/parser.scm: Import '(gash compat)'; remove '(srfi srfi-14)'
import.
(eof-object): Remove procedure.
(make-parser): Replace 'eof-object' with 'the-eof-object'.
(call-with-backquoted-input-port): Likewise.
2023-02-08 14:29:13 -06:00
Timothy Sample e37ef0faba lexer: Port to Mes.
* gash/compat.scm [mes] (define-inlinable): New syntax.
[mes] (*fluid-accessor*): New variable.
[mes] (make-parameter): New procedure.
[mes] (parameterize): New syntax.
[mes] (set-port-line!): New procedure.
[mes] (string-every): New procedure.
* gash/compat/textual-ports.scm [mes] (<soft-input-port>): New
record type.
[mes] (make-soft-port): New procedure.
[mes] (push-soft-input-port-buffer!): New procedure.
[mes] (pop-soft-input-port-buffer!): New procedure.
[mes] (get-char): New procedure.
[mes] (unget-char): New procedure.
[mes] (lookahead-char): New procedure.
* gash/lexer.scm: Import '(gash compat)' and '(srfi srfi-14)'.
2023-02-08 14:29:05 -06:00
Timothy Sample ead347128a compat: Support Mes.
* gash/compat.scm (if-guile-version-below) [mes]: Do nothing.
(when-mes): New syntax.
* .dir-locals.el: Tell Emacs how to indent it.
2022-04-28 15:47:36 -06:00
Timothy Sample a3123ab02a Update NEWS for 0.3.0.
* NEWS (release 0.3.0): New section.
2022-02-11 11:18:55 -05:00
Timothy Sample ec009a89bb Update ChangeLog copyright years.
* ChangeLog: Update copyright years for Timothy Sample.
2022-02-11 10:43:58 -05:00
Timothy Sample d0d90d0956 Support Guile 3.0.
* configure.ac (GUILE_PKG): Add '3.0'.
* guix.scm: Use 'guile-3.0' for the Gash package.
2022-02-11 10:22:19 -05:00
Timothy Sample eae0953f31 parser: Simplify default port handling.
* gash/parser.scm (read-sh, read-sh-all): Set the default value for
the 'port' argument in the usual way (rather than doing it
manually).
2021-06-23 14:27:40 -04:00
Timothy Sample 57d21182e2 parser: Fix port name typo.
* gash/parser.scm (read-sh): Read from 'current-input-port' instead
of 'current-output-port'.
2021-06-23 14:19:20 -04:00
Timothy Sample 87229e4b3a Add arithmetic expansion.
* gash/arithmetic.scm: New file.
* Makefile.am (SOURCES): Add it.
* gash/lexer.scm (get-arithmetic-expansion): New procedure.
(get-expansion): Check for "$((" and use the new procedure to read an
arithmetic expansion.
* gash/eval.scm (word->qword): Handle '<sh-arithmetic>'.
* tests/unit/eval.scm: Add tests.
* tests/spec/Makefile.am (TESTS): Add 'arith'.
* tests/spec/oil.scm: Patch seven of its tests and filter out fifteen
others.
* doc/gash.texi, doc/syntax.txt: Add '<sh-arithmetic>' syntax.
2021-05-26 13:16:50 -04:00
Timothy Sample d3244e0ec0 Move evaluation code from 'word' to 'eval'.
This adjustment paves the way for writing a compiler.

* gash/word.scm (eval-cmd-sub, string-not-null?, word->qword,
expand-word): Move these...
* gash/eval.scm: ...to this module.
* tests/unit/word.scm: Adjust qword tests to use 'expand-qword', and
move non-qword (evaluation) tests to...
* tests/unit/eval.scm: ...this new file, adjusting them to use
'eval-word'.
* Makefile.am (UNIT_TESTS): Add the new file.
2021-04-19 15:11:27 -04:00
Timothy Sample 2bce1ea07b Add an 'expand-qword' procedure.
* gash/word.scm (expand-qword): New procedure.
(expand-word): Rewrite in terms of 'expand-qword'.
2021-04-19 15:09:16 -04:00
Timothy Sample 1e88c314d6 Fix long lines in the examples in the manual.
* doc/gash.texi (Internal representation examples): Fix long lines
in examples.
2021-04-16 21:35:42 -04:00
Timothy Sample 18ecd7d142 Correct ice cream parsing example in the manual.
* doc/gash.texi (Internal representation examples): In the section
on pipelines, change a redirect in the result to "ice-cream.txt" to
match its input.
2021-04-16 21:31:45 -04:00
Timothy Sample 1e752e54bf Remove asynchronous commands as a missing feature.
* doc/gash.texi (Missing features): Remove asynchronous commands
from the list.
2020-08-21 16:15:17 -04:00
Timothy Sample 9f9a866b19 List variable operators as working in the manual.
* doc/gash.texi (Using Gash): Specify that all the variable
operators work.
(Missing features): Remove the bullet point about variable
operators.
2020-08-21 16:07:16 -04:00
Stephen J. Scheck 8f9b973264 Add a language specification.
* language/sh/spec.scm: New file.
* Makefile.am (SOURCES): Add it.
* doc/gash.texi (Using Gash from the Guile REPL): New section.
2020-08-21 15:49:24 -04:00
Timothy Sample 8cbb4803c8 Reset status on empty commands.
* gash/eval.scm (exp->thunk, exps->thunk): When the expression has
value '#f', reset the status.
2020-03-30 23:36:42 -04:00