Commit Graph

578 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen bca65e807b Support ${foob-bar} and ${foo+bar}.
* gash/environment.scm (variable): Add default parameter.
(variable-or, variable-and): New function.
* test/07-variable-or.sh: Test it.
* test/07-variable-or-not.sh:
* test/08-variable-and.sh:
* test/08-variable-and-not.sh:
2018-11-05 20:13:26 +01:00
Jan Nieuwenhuizen 418652bee1 test: Refactor. 2018-11-05 20:13:26 +01:00
Jan Nieuwenhuizen a0ff0853ff set: Support -u, clumped singles.
* gash/builtins.scm (set-command): Support -u, clumped singles.
* gash/environment.scm (variable): Consider `nounset'.  TODO:
propagate error.
2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen ac30e252bd Make dependency on geesh optional. 2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen 992e12444d chmod: New builtin.
* gash/commands/chmod.scm: New file.
* build-aux/build-guile.sh: Compile it.
* .gitignore: Ignore it.
2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen 6175b07c7e pipe: Connect stderr too.
* gash/pipe.scm (spawn): Connect stderr too.
2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen aafbc96dbd rm: Resurrect.
* gash/commands/rm.scm: Resurrect.
* gash/bournish-commands.scm: Add it.
* build-aux/build-guile.sh: Compile it.
* .gitignore: Ignore it.
2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen 6224bbeefc test: tar. 2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen ab4ce3b995 test: Add check-geesh. 2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen 6203f8cf07 test: Update test suite. 2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen 1f9480cda1 Guile As SHell. 2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen d626cdb136 build: Fixes.
* build-aux/trace.sh: Import from Mes.
* build-aux/build-guile.sh: Update from Mes.
* makefile: Avoid endless reconfigure.
2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen f27cb9a192 sed: New builtin.
* gash/commands/sed.scm: New file.
* build-aux/build-guile.sh: Compile it.
* configure: Create script.
* gash/shell-utils.scm (with-atomic-file-replacement,
substitute*): New function, Import from Guix.
(substitute-port): New function.
2018-11-05 19:59:53 +01:00
Jan Nieuwenhuizen 9d1d2be6a6 test: Add expectations.
* check.sh: New file, from test.sh.
* test.sh: Run single test with expectations.
2018-11-03 08:02:49 +01:00
Jan Nieuwenhuizen b433052b4a builtins: Split out into gash/commands/.
* gash/commands/cat.scm: New file, expand from bournish-commands.scm.
* gash/commands/compress.scm: Likewise.
* gash/commands/cp.scm: Likewise.
* gash/commands/find.scm: Likewise.
* gash/commands/grep.scm: Likewise.
* gash/commands/ls.scm: Likewise.
* gash/commands/reboot.scm: Likewise.
* gash/commands/tar.scm: Likewise.
* gash/commands/wc.scm: Likewise.
* gash/commands/which.scm: Likewise.
* build-aux/pre-inst-env.in: New file.
* configure: Expand it.
* gash/bournish-commands.scm: Remove.
* gash/shell-utils.scm: Rename from guix-build-utils.scm.
2018-11-03 08:02:49 +01: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
Jan Nieuwenhuizen 1e5389f01d builtins: Oops, have \NAME run builtin.
* gash/script.scm (command): Oops have \NAME run builtin.
(pipeline): Filter-out #<unspecified> (xtrace residue).
2018-10-30 17:39:05 +01:00
Jan Nieuwenhuizen 3e8b021f0b bournish: Do not display help if --version is requested.
* gash/bournish-commands.scm (ls-command-implementation): Do not
display help if --version is requested.
(find-command-implementation): Likewise.
(grep-command): Likewise.
(tar-command): Likewise.
(compress-command): Likewise.
2018-10-29 22:55:05 +01:00
Jan Nieuwenhuizen 5296fdbf2c tar: Use latin-1 (binary) codec instead of utf8. 2018-10-29 22:55:05 +01:00
Jan Nieuwenhuizen b463aa32bc tar: Handle extracting of directories.
* gash/ustar.scm (read-ustar-file): Do not dump content of directory.
Size is 0; do not start by reading 512 bytes.
2018-10-29 22:55:05 +01:00
Jan Nieuwenhuizen 1fd796bad7 guix: build fixes.
* bin/builtin.in: Remove gratuitous quotes.
* configure (BUILTINS): Add bash and sh scripts.
* gash/builtins.scm (command-command): Add missing format parameter.
(type-command): Likewise.
* gash/guix-build-utils.scm: Use (ice-9 format).
* gash/guix-utils.scm: Likewise.
* gash/ustar.scm (write-ustar-port): Remove catch.
(read-ustar-port): Likewise.
2018-10-29 22:09:34 +01:00
Jan Nieuwenhuizen f7c1dd6e72 Make readline optional.
* gash/readline.scm: New file.
* build-aux/build-guile.sh: Compile it.
* gash/gash.scm: Use it as fallback.
2018-10-29 21:22:32 +01:00
Jan Nieuwenhuizen d2133b8502 tar: Support old cvf/xvf and auto-compress.
* gash/bournish-commands.scm (tar-command): Support old cvf/xvf and
auto compress (use archive suffix to determine the compression.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen a10247aab1 tar: Support compression.
* gash/guix-utils.scm: New file, partial import from Guix.
Throughout: Add `compress.'
* build-aux/build-guile.sh: Compile it.
* gash/config.scm.in: Support it by defining compressors.
* configure: Substitute them.
* gash/bournish-commands.scm (tar-command): Use it to have tar support
compression and decompression.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen e3e20738c2 tar: Handle stdin, stdout.
* gash/ustar.scm (list-ustar-port, extract-ustar-port,
write-ustar-port): New function.
* gash/bournish-commands.scm (tar-command): Use them.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 8b56dcc2ab compress: play nice with GNU tar.
* gash/bournish-commands.scm (compress-command): Compress/decompress
from stdin if not tty.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 975f53d98e bournish: Add compress, from Guile100 challenge by Daniel Hartwig. WIP 2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 8aad645152 ls: Support -l.
* gash/bournish-commands.scm (ls-command-implementation): Support -l.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 4e671558e5 tar: Nicer verbose listing of files.
* gash/guix-build-utils.scm (display-file): New function.
* gash/ustar.scm (display-header): Use it.
(ustar-header->stat): New function.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 28d62b6169 tar: Support --list and --verbose.
* gash/ustar.scm (extract-ustar-file): Add keyword argument: extract?
(extract-ustar-archive): Add keyword arguments: extract?, verbose?:
(display-rwx, display-header, list-ustar-archive): New function
* gash/bournish-commands.scm (tar-command): Support --list, --verbose.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 463b71acc9 tar: Support creation of deterministic archives.
* gash/ustar.scm (write-ustar-header, write-ustar-file): Accept
keyword arguments: group mtime numeric-owner? owner.
(create-ustar-archive): Likewise.  Rename from write-ustar-archive.
* gash/bournish-commands.scm (tar-command): Support --group, --mtime,
--numeric-owner, --owner and --sort.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 92d2896134 tar: Support extraction.
* gash/ustar.scm (extract-ustar-file):
* gash/ustar.scm (<ustar-header>): New record type.
(bv->ustar-string, bv->ustar-number, bv->ustar-0string,
sub-bytevector, read-ustar-header, extract-ustar-file): New function.
Implement extraction.
2018-10-29 14:51:00 +01:00
Jan Nieuwenhuizen 03fc5c928a Add mkdir-p.
* gash/guix-build-utils.scm (mkdir-p): New function, import from Guix.
2018-10-27 11:31:22 +02:00
Jan Nieuwenhuizen 3c57272971 Add delete-file-recursively.
* gash/guix-build-utils.scm (delete-file-recursively): New function,
import from Guix.
2018-10-27 11:31:22 +02:00
Jan Nieuwenhuizen 904eecbb2c Expose all bournish commands as external command.
* bin/builtin.in: New file.
* bin/tar.in: Remove.
* configure: Generate bin/<builtin> for all bournish-commands.
* build-aux/build-guile.sh: Compile them.
* .gitignore: Ignore them.
2018-10-27 11:31:22 +02:00
Jan Nieuwenhuizen 70d28ea480 Make tar a bournish-command.
* bin/gash.in: Make Scheme script.
* bin/tar.in: Likewise.
* gash/bournish-commands (tar-command): New command, move from
tar.scm.
(%bournish-commands): Add it.
* gash/tar.scm: Remove.
2018-10-27 11:31:22 +02:00
Jan Nieuwenhuizen b8b170530c bournish: Add tar, from Guile100 challenge by Mark Weaver.
See https://github.com/spk121/guile100

* bin/tar.in: New file.
* configure: Produce bin/tar.
* .gitignore: Ignore it.
* makefile (bin/tar): New target.
* gash/tar.scm: New file.
* gash/ustar.scm: New file.
* build-aux/build-guile.sh: Compile new files.
2018-10-27 11:30:45 +02:00
Jan Nieuwenhuizen 019464acf6 fix: set -e. 2018-10-21 16:13:29 +02:00
Jan Nieuwenhuizen 13cb50af60 gash: resurrect. 2018-10-21 15:24:24 +02:00
Jan Nieuwenhuizen 0f5b538c3a geesh: initial integration.
GUILE_LOAD_PATH=$HOME/src/geesh:$GUILE_LOAD_PATH
    GUILE_LOAD_COMPILED_PATH=$HOME/src/geesh:$GUILE_LOAD_COMPILED_PATH

    bin/gash --parse -c 'echo boo | sed s,o,O, | grep .'
    bin/gash --geesh --parse -c 'echo boo | sed s,o,O, | grep .'
2018-10-21 12:45:51 +02: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
Timothy Sample c79cea756d Rename '<sh-pipe>' to '<sh-pipeline>'
* doc/syntax.txt: Rename '<sh-pipe>' to '<sh-pipeline>'.
* geesh/parser.scm (make-parser): Ditto.
* tests/parser.scm: Fix test accordingly.
2018-07-19 01:19:00 -04:00
Timothy Sample f149d42b82 Add '<sh-not>' to syntax document
* doc/syntax.txt: Add '<sh-not>'.
2018-07-19 01:04:28 -04:00
Timothy Sample 12b0354233 Rename '<sh-bang>' to '<sh-not>'
* geesh/parser.scm (make-parser): Rename '<sh-bang>' to '<sh-not>'.
2018-07-19 01:02:08 -04:00
Timothy Sample 2aa8615f9e Update AST for command substitutions
The AST generated by the parser did not match the syntax document.
However, neither were right.  This commit updates the syntax document
to describe a more consistent form, and fixes the code to follow it.

* doc/syntax.txt (word): Make the children of '<sh-cmd-sub>' a
possibly empty list of 'list's.
* geesh/lexer.scm (get-bracketed-command): Splice in children for
'<sh-cmd-sub>'.
(get-backquoted-command): Ditto.
* geesh/parser.scm (read-sh/bracketed): Make sure that result is
always a list.
(read-sh/backquoted): Ditto.
* tests/lexer.scm: Update tests accordingly.
* tests/parser.scm: Ditto.
2018-07-18 14:27:11 -04:00
Timothy Sample 4f1e737cdd Make test examples more plausible
* tests/lexer.scm: Replace fake '<sh-cmd>' forms with '<sh-exec>'.
2018-07-18 14:23:01 -04:00
Timothy Sample 5605ea993a Fix AST for quoted words
* geesh/lexer.scm (get-double-quotation): Make sure that '<sh-quote>'
forms only have one sub-word.
(get-unquoted-here-doc): Ditto.
* tests/lexer.scm: Update tests accordingly.
2018-07-18 09:29:33 -04:00
Timothy Sample a2f5403367 Fix field splitting on outside spaces
* geesh/word.scm (split-fields): Make outside spaces in word-parts
count for field splitting.
* tests/word.scm: Test this.
2018-07-18 02:33:08 -04:00
Timothy Sample da1d561f22 Fix AST to prevent empty '<sh-exec-let>' bindings
Commands with prefix redirects and no arguments or assignments would
generate '<sh-exec-let>' forms with an empty list for bindings.

* geesh/parser.scm (make-parser): Check for and handle an empty
assignment list.
* tests/parser.scm: Add test.
2018-07-17 22:27:10 -04:00
Timothy Sample 8b945a77a9 Fix reading multi-line quoted here-documents
* geesh/lexer.scm (get-quoted-here-doc): Use the correct line-reading
procedure when looping.
* tests/lexer.scm: Add test.
2018-07-17 21:59:09 -04:00