Commit Graph

471 Commits

Author SHA1 Message Date
Timothy Sample a43d97dd09 Add here-document support to the lexer
* geesh/lexer.scm (get-quoted-here-doc): New function.
(get-unquoted-here-doc): New function.
(wrap-port-with-tab-trimming): New function.
(get-here-doc): New public function.
* tests/lexer.scm: Test it.
2018-07-15 20:16:17 -04:00
Timothy Sample be5b305de6 Fix dollar sign handling before non-name
If a dollar sign does not precede a name, it gets treated normally.

* geesh/lexer.scm (get-parameter): Return '#f' if the first character
is not a name character.
(get-parameter-expansion): Propagate the '#f' value.
(get-word): Replace the '#f' value with last character read.
(get-parameter-word): Ditto.
(get-double-quotation): Ditto.
* tests/lexer.scm: Test this.
2018-07-15 19:48:20 -04:00
Timothy Sample 01e8a7bf24 Fix line-joining when there are extra spaces
* geesh/lexer.scm (get-token): Add a case to skip an escaped newline.
* tests/lexer.scm: Test it.
2018-07-15 19:48:20 -04:00
Timothy Sample faf89ad173 Delay processing of dup redirect words
The right-hand side of a dup redirect ("<&" and ">&") may contain
expansions, so we cannot process it during parsing.

* geesh/parser.scm (process-dup-or-close-word): Remove function.
(make-parser): Return the raw word from a dup redirect instead of
trying to convert it into a number or a symbol.
* tests/parser.scm: Fix tests accordingly.
2018-07-15 19:47:10 -04:00
Timothy Sample 7cf2c3d806 Fix handling of reserved words in commands
A reserved word should not be special when it is an argument to a
command.  This commit makes the parser treat reserved words as normal
arguments.  Note that this change exposed problems in many of the
parser tests, which relied on reserved words delimiting commands where
they should not.  Those are now fixed.

* geesh/parser.scm (make-parser): Add reserved words to the default
'WORD*' rule, and use a new rule without reserved words for command
names.
* tests/parser.scm: Add a test for reserved words as arguments, and
fix old tests that relied on the old, incorrect behaviour.
2018-07-15 19:46:14 -04:00
Timothy Sample 7d27433a32 Use '<sh-begin>' for lists of commands
* geesh/parser.scm (make-parser): Put '<sh-begin>' at the beginning of
lists of commands.
* tests/parser.scm: Update tests accordingly.
2018-07-15 19:46:14 -04:00
Timothy Sample a5773e90eb Add word
* geesh/word.scm: New file.
* tests/word.scm: New file.
* Makefile.am: Add them.
2018-07-15 19:46:14 -04:00
Timothy Sample e410d1eac3 Add missing license prefix
* tests/parser.scm: Add missing license prefix.
2018-07-15 19:46:14 -04:00
Timothy Sample 6678ae1e59 Add environment
* geesh/environment.scm: New file.
* tests/environment.scm: New file.
* Makefile.am: Add them.
2018-07-15 19:46:14 -04:00
Timothy Sample 2b05199562 Flatten AST form for multiple assignments
* geesh/parser.scm (make-parser): Instead of using a nested list for
assignments, use a flat list.
* tests/parser.scm: Adjust existing test for this (which checks a
single assignment) and add a second test which checks multiple
assignments.
2018-07-15 19:45:31 -04:00
Jan Nieuwenhuizen 292fbc5ecb test/if.sh, test/if2.sh -- weird 2018-07-15 23:27:58 +02:00
Jan Nieuwenhuizen 6468b04791 refactor WORD...bummer: word-for-test-assign-sh word-for-test-if-sh 2018-07-15 23:01:52 +02:00
Jan Nieuwenhuizen 24c35cc5d9 checkpoint 2018-07-15 21:44:15 +02:00
Jan Nieuwenhuizen 1f5c82ecae word! test/if.sh, test/assign.sh 2018-07-15 21:35:42 +02:00
Jan Nieuwenhuizen cbd13fdc88 checkpoint 2018-07-15 20:49:52 +02:00
Jan Nieuwenhuizen e7bfd347fa checkpoint 2018-07-15 20:47:09 +02:00
Jan Nieuwenhuizen 83f20d1ff8 flatten-fu 2018-07-15 20:06:19 +02:00
Jan Nieuwenhuizen e9a57a899c more for-progress 2018-07-15 18:39:17 +02:00
Jan Nieuwenhuizen bfc39b1a18 test: implement -n, -z, !=. 2018-07-15 18:19:56 +02:00
Jan Nieuwenhuizen 8f8ba68c54 resurrect set -x 2018-07-15 18:18:34 +02:00
Jan Nieuwenhuizen 85b90e8537 job: disable backgrounding 2018-07-15 16:32:43 +02:00
Jan Nieuwenhuizen e6e03c6da2 parser: handle substitution in for sequence. 2018-07-15 16:08:26 +02:00
Jan Nieuwenhuizen c32034d13d command, builtin, glob, echo cleanup and fixes 2018-07-15 13:43:52 +02:00
Jan Nieuwenhuizen d065723221 parser: refactor, use `pipeline' instead of `expression'. 2018-07-15 12:49:59 +02:00
Jan Nieuwenhuizen 9623e014f0 builtins: [: New command.
* gash/builtins (bracket-command): New function.
  (%builtin-commands): Add it.
2018-07-15 12:23:27 +02:00
Jan Nieuwenhuizen 4bb60cc4c3 parse: handle empty script WIP 2018-07-14 23:16:27 +02:00
Jan Nieuwenhuizen b20306e123 builtins: grep: New command.
* gash/guix-build-utils.scm (<grep-match>): New record type.
  (grep): New function.
* gash/builtins.scm (grep-command): New command.
  (%builtin-commands): Add it.
2018-07-14 23:16:27 +02:00
Jan Nieuwenhuizen 0cab9321b2 builtins: test: Enhance with file tests.
* gash/guix-build-utils.scm (directory-exists?, executable-file?,
  symbolic-link?): Import from Guix.
* gash/builtins.scm (test-command): Use them to enhance with file test.
2018-07-14 23:16:27 +02:00
Jan Nieuwenhuizen 863b3b5908 builtins: test: New command.
* gash/builtins.scm (test-command): New command.
  (%builtin-commands): Add it.
  (builtin, command, doublequotes, expression, for, glob,
  singlequotes, substitution): Move from peg.scm.
* gash/peg.scm: Remove them.
2018-07-14 23:16:13 +02:00
Jan Nieuwenhuizen 48373edb3f WIP: IF hack 2018-07-14 22:48:55 +02:00
Jan Nieuwenhuizen de6d653c7c builtins: type: New command.
* gash/builtins.scm (type-command): New function.
  (%builtin-commands): Add it.
2018-07-14 22:48:55 +02:00
Jan Nieuwenhuizen 677deaf9b3 builtins: command: New command.
* gash/builtins.scm   (command-command): New command.
  (%builtin-commands): Add it.
  (builtin): Move from peg.
* gash/peg.scm (builtin): Remove.
2018-07-14 22:48:42 +02:00
Jan Nieuwenhuizen 0408463a13 bah, some uninformed error handling. WIP 2018-07-14 22:48:42 +02:00
Jan Nieuwenhuizen 870fc792d7 debug du WIP 2018-07-14 22:48:42 +02:00
Jan Nieuwenhuizen 2c30f3c4c6 builtins: find: First naive implementation.
* gash/builtins.scm (find-command-implementation): New function.
  (find-command): New command.
  (%builtin-commands): Add it.
* gash/guix-build-utils.scm (file-name-predicate, find-files): Import
  from Guix.
2018-07-14 22:48:42 +02:00
Jan Nieuwenhuizen e0169d0acd builtins: Support \non-builtin escape.
* gash/peg.scm (builtin): Add #:prefer-builtin? keyword argument.
  (transform): Support \non-builtin escape.
2018-07-14 15:57:02 +02:00
Jan Nieuwenhuizen e5c6324d82 remove debugging WIP: 2018-07-14 15:56:46 +02:00
Jan Nieuwenhuizen 43d418fab1 some builtin progress WIP 2018-07-14 15:41:03 +02:00
Jan Nieuwenhuizen 97a95ee002 builtins: cd: Support `cd -'.
* gash/builtins.scm (cd-command): Support `cd -'.
2018-07-14 15:23:52 +02:00
Jan Nieuwenhuizen 56a36baee5 factor-out environment.
* gash/environment.scm: New file.
* build-aux/build-guile.sh (SCM_FILES): Add it.
* gash/peg.scm: Include it.
  (assignment, %global-variables, set-shell-opt!, variable): Remove.
2018-07-14 15:23:52 +02:00
Jan Nieuwenhuizen 23a13b0890 builtins: resurrect pwd WIP 2018-07-14 15:23:52 +02:00
Jan Nieuwenhuizen 3ea368ab2f resurrect help WIP 2018-07-14 15:23:52 +02:00
Jan Nieuwenhuizen 40aa82fca9 builtins: ls: Support -a,--all,-1,--one-file-per-line,-h,--version.
* gash/bournish-commands.scm (ls-command-implementation): Support
  -a,--all,-1,--one-file-per-line,-h,--version.
2018-07-14 15:23:21 +02:00
Jan Nieuwenhuizen 512b848b11 build: Add config.scm.in.
* gash/config.scm.in:
* configure: Use it to generate gash/config.scm
* .gitignore: Ignore generated file.
* gash/gash.scm (display-version): Use it.
* build-aux/build-guile.sh: Compile it.
2018-07-14 15:10:44 +02:00
Jan Nieuwenhuizen c896015068 resurrect builtins: WIP 2018-07-14 13:34:10 +02:00
Rutger van Beusekom f5339a09f5 WIP: marginal 2018-07-14 12:34:42 +02:00
Jan Nieuwenhuizen 4d3751f654 resurrect builtins: WIP 2018-07-14 12:24:51 +02:00
Jan Nieuwenhuizen f3c8c2c7f0 exit-stati: WIP 2018-07-14 10:20:05 +02:00
Jan Nieuwenhuizen 42fbcb942a fix exit-status in `command' 2018-07-14 09:46:30 +02:00
Jan Nieuwenhuizen ff985aa083 verder aangehaakt 2018-07-14 09:34:57 +02:00