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-02-15 00:55:07 +00:00
|
|
|
|
;;; Gash -- Guile As SHell
|
2019-12-02 03:14:19 +00:00
|
|
|
|
;;; Copyright © 2018, 2019 Timothy Sample <samplet@ngyro.com>
|
|
|
|
|
;;;
|
|
|
|
|
;;; The 'mock' syntax was taken from the 'guix/tests.scm' file in GNU
|
|
|
|
|
;;; Guix, which has the following copyright notice:
|
|
|
|
|
;;;
|
|
|
|
|
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
2018-07-12 03:05:15 +01:00
|
|
|
|
;;;
|
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-02-15 00:55:07 +00:00
|
|
|
|
;;; This file is part of Gash.
|
2018-07-12 03:05:15 +01:00
|
|
|
|
;;;
|
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-02-15 00:55:07 +00:00
|
|
|
|
;;; Gash is free software: you can redistribute it and/or modify
|
2018-07-12 03:05:15 +01:00
|
|
|
|
;;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;;; (at your option) any later version.
|
|
|
|
|
;;;
|
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-02-15 00:55:07 +00:00
|
|
|
|
;;; Gash is distributed in the hope that it will be useful,
|
2018-07-12 03:05:15 +01:00
|
|
|
|
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
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-02-15 00:55:07 +00:00
|
|
|
|
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(define-module (test-word)
|
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-02-15 00:55:07 +00:00
|
|
|
|
#:use-module (gash environment)
|
|
|
|
|
#:use-module (gash word)
|
2019-12-02 03:14:19 +00:00
|
|
|
|
#:use-module (ice-9 i18n)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:use-module (srfi srfi-1)
|
2018-07-12 03:05:15 +01:00
|
|
|
|
#:use-module (srfi srfi-64)
|
2018-12-12 19:23:09 +00:00
|
|
|
|
#:use-module (tests unit automake))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; Tests for the word module.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2019-12-02 03:14:19 +00:00
|
|
|
|
(define-syntax-rule (mock (module proc replacement) body ...)
|
|
|
|
|
"Within @var{body}, replace the definition of @var{proc} from
|
|
|
|
|
@var{module} with the definition given by @var{replacement}."
|
|
|
|
|
(let* ((m (resolve-module 'module))
|
|
|
|
|
(original (module-ref m 'proc)))
|
|
|
|
|
(dynamic-wind
|
|
|
|
|
(lambda () (module-set! m 'proc replacement))
|
|
|
|
|
(lambda () body ...)
|
|
|
|
|
(lambda () (module-set! m 'proc original)))))
|
|
|
|
|
|
|
|
|
|
(define (make-pure-scandir files pwd)
|
|
|
|
|
"Return a procedure that acts like @code{scandir} but instead of
|
|
|
|
|
using the real filesystem it resolves queries by looking at
|
|
|
|
|
@var{files}. To scan relative paths, the procedure will use
|
|
|
|
|
@var{pwd}."
|
|
|
|
|
(define (list-directory select? parents base path)
|
|
|
|
|
(match path
|
|
|
|
|
(()
|
|
|
|
|
(match base
|
|
|
|
|
((base-name . children)
|
|
|
|
|
(filter select?
|
|
|
|
|
(cons* "." ".."
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((name . _) name)
|
|
|
|
|
(name name))
|
|
|
|
|
children))))
|
|
|
|
|
(base-name #f)))
|
|
|
|
|
(((or "" ".") . rest)
|
|
|
|
|
(list-directory select? parents base rest))
|
|
|
|
|
((".." . rest)
|
|
|
|
|
(match parents
|
|
|
|
|
((parent)
|
|
|
|
|
(list-directory select? parents parent rest))
|
|
|
|
|
((parent . grandparents)
|
|
|
|
|
(list-directory select? grandparents parent rest))))
|
|
|
|
|
((component . rest)
|
|
|
|
|
(match base
|
|
|
|
|
((base-name . children)
|
|
|
|
|
(let ((child (find (match-lambda
|
|
|
|
|
((name . _) (string=? name component))
|
|
|
|
|
(name (string=? name component)))
|
|
|
|
|
children)))
|
|
|
|
|
(and child
|
|
|
|
|
(list-directory select? (cons base parents) child rest))))
|
|
|
|
|
(base-name #f)))))
|
|
|
|
|
|
|
|
|
|
(lambda* (path #:optional (select? (const #t)) (entry<? string-locale<?))
|
|
|
|
|
(if (string-null? path)
|
|
|
|
|
#f
|
|
|
|
|
(and=> (let* ((path* (if (string-prefix? "/" path)
|
|
|
|
|
path
|
|
|
|
|
(string-append pwd "/" path)))
|
|
|
|
|
(split-path (string-split path* #\/)))
|
|
|
|
|
(list-directory select? (list files) files split-path))
|
|
|
|
|
(lambda (entries) (sort entries entry<?))))))
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (with-mocked-files files body ...)
|
|
|
|
|
"Mock filesystem-accessing procedures used in pathname expansion so
|
|
|
|
|
that within @var{body}, the filesystem seems as though it contains
|
|
|
|
|
only @var{files}. As a bonus, the value of the Gash environment
|
|
|
|
|
variable @var{PWD} will be restored when leaving the extent of
|
|
|
|
|
@var{body}."
|
|
|
|
|
(let ((saved-pwd #f))
|
|
|
|
|
(dynamic-wind
|
|
|
|
|
(lambda () (set! saved-pwd (getvar "PWD")))
|
|
|
|
|
(lambda ()
|
|
|
|
|
(mock ((ice-9 ftw) scandir (make-pure-scandir files "/"))
|
|
|
|
|
body ...))
|
|
|
|
|
(lambda () (setvar! "PWD" saved-pwd)))))
|
|
|
|
|
|
2018-07-12 03:05:15 +01:00
|
|
|
|
(test-begin "word")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Basic string handling.
|
|
|
|
|
|
|
|
|
|
(test-equal "Converts a simple word (string) to a single field"
|
|
|
|
|
'("foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "foo"))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Converts a simple word (list) to a single field"
|
|
|
|
|
'("foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Concatenates contiguous parts into a single field"
|
|
|
|
|
'("foobar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo" "bar")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Splits a word along unquoted spaces"
|
|
|
|
|
'("foo" "bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo bar")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
2018-07-18 07:33:08 +01:00
|
|
|
|
(test-equal "Splits a word on leading space"
|
|
|
|
|
'("foo" "bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo" " bar")))
|
2018-07-18 07:33:08 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Splits a word on trailing space"
|
|
|
|
|
'("foo" "bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo " "bar")))
|
2018-07-18 07:33:08 +01:00
|
|
|
|
|
2018-07-12 03:05:15 +01:00
|
|
|
|
(test-equal "Ignores leading spaces"
|
|
|
|
|
'("foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '(" foo")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Ignores trailing spaces"
|
|
|
|
|
'("foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo ")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Treats multiple spaces as a single space"
|
|
|
|
|
'("foo" "bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo bar")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Handles multiple joins and splits"
|
|
|
|
|
'("hi_how" "are_you")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("hi_" "how are" "_you")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
2018-11-10 22:35:41 +00:00
|
|
|
|
(test-equal "Handles nested lists"
|
|
|
|
|
'("foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("f" ("oo"))))
|
2018-11-10 22:35:41 +00:00
|
|
|
|
|
2019-10-10 18:32:40 +01:00
|
|
|
|
(test-equal "Handles nested lists for string output"
|
|
|
|
|
"foo"
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("f" ("oo")) #:output 'string))
|
2019-10-10 18:32:40 +01:00
|
|
|
|
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
;;; Quotes.
|
|
|
|
|
|
|
|
|
|
(test-equal "Ignores spaces in quotes"
|
|
|
|
|
'("foo bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '(<sh-quote> "foo bar")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Concatenates strings and quotes"
|
|
|
|
|
'("foo bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo" (<sh-quote> " bar"))))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Concatenates quotes"
|
|
|
|
|
'("foo bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '((<sh-quote> "foo") (<sh-quote> " bar"))))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Handles nested quotes"
|
|
|
|
|
'("foo bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '(<sh-quote> (<sh-quote> "foo bar"))))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-equal "Splits and concatenates words and quotes"
|
|
|
|
|
'("foo" "bar")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '((<sh-quote> "foo") " " (<sh-quote> "bar"))))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Tildes.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Not yet implemented.
|
|
|
|
|
|
|
|
|
|
|
2019-12-02 03:14:19 +00:00
|
|
|
|
;;; Pathname expansion.
|
|
|
|
|
|
|
|
|
|
(test-equal "Expands pathnames"
|
|
|
|
|
'("a" "b" "c")
|
|
|
|
|
(with-mocked-files '("" ("foo" "a" "b" "c"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Sorts expanded pathnames"
|
|
|
|
|
'("a" "b" "c")
|
|
|
|
|
(with-mocked-files '("" ("foo" "c" "b" "a"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Expands absolute pathnamess"
|
|
|
|
|
'("/foo/a" "/foo/b")
|
|
|
|
|
(with-mocked-files '("" ("foo" "a" "b"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "/foo/*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Paths with trailing slashes get expanded"
|
|
|
|
|
'("foo/")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar") "baz")
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "*/")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Expands patterns in the middle of a path"
|
|
|
|
|
'("/bar/a" "/foo/a")
|
|
|
|
|
(with-mocked-files '("" ("bar" "a") ("foo" "a"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "/*/a")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Does not expand quoted patterns"
|
|
|
|
|
'("*")
|
|
|
|
|
(with-mocked-files '("" ("foo" "a" "b" "c"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '(<sh-quote> "*"))))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Pathname expansion works when slashes are quoted"
|
|
|
|
|
'("foo/bar")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo" (<sh-quote> "/") "*"))))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Pathname expansion works when slashes are patterns"
|
|
|
|
|
'("f[o/b]r")
|
|
|
|
|
(with-mocked-files '("" ("f[o" "b]r"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "f[o/b]*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Pathname expansion works when slashes are broken patterns"
|
|
|
|
|
'("f[o/bar")
|
|
|
|
|
(with-mocked-files '("" ("f[o" "bar"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "f[o/*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Does not implicitly match dotted files"
|
|
|
|
|
'("baz")
|
|
|
|
|
(with-mocked-files '("" ("foo" ".bar" "baz"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Explicitly matches dotted files"
|
|
|
|
|
'("." ".." ".bar")
|
|
|
|
|
(with-mocked-files '("" ("foo" ".bar" "baz"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword ".*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
;; This is left unspecified in POSIX, so we follow Bash.
|
|
|
|
|
(test-equal "Bracked dots are not explicit enough"
|
|
|
|
|
'("[.]*")
|
|
|
|
|
(with-mocked-files '("" ("foo" ".bar" "baz"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "[.]*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Paths with duplicate slashes get expanded"
|
|
|
|
|
'("foo///bar")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "foo///*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Absolute paths with duplicate slashes get expanded"
|
|
|
|
|
'("///foo/bar")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "///foo/*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
;; Bash does not preserve the duplicate slashes, but Dash does, and it
|
|
|
|
|
;; seems like the more consistent thing to do.
|
|
|
|
|
(test-equal "Paths with duplicate trailing slashes get expanded"
|
|
|
|
|
'("foo///")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar") "baz")
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "*///")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Paths with dot nodes get expanded"
|
|
|
|
|
'("./foo/./bar")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar"))
|
|
|
|
|
(setvar! "PWD" "/")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "./foo/./*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Paths with dot-dot nodes get expanded"
|
|
|
|
|
'("../foo/../foo/bar")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword "../*/../*/*")))
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Patterns matching dot-dot get expanded"
|
|
|
|
|
'("../foo")
|
|
|
|
|
(with-mocked-files '("" ("foo" "bar"))
|
|
|
|
|
(setvar! "PWD" "/foo")
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword ".*/f*")))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Field splitting (IFS)
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Respects IFS value"
|
|
|
|
|
'("foo" "bar")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "-"))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo-bar")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Combines multiple whitespace separators"
|
|
|
|
|
'("foo" "bar")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . " "))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo bar")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Keeps multiple non-whitespace separators"
|
|
|
|
|
'("foo" "" "bar")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "-"))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo--bar")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Combines whitespace separators with a non-whitespace separator"
|
|
|
|
|
'("foo" "bar")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "- "))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo - bar")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Keeps multiple non-whitespace separators with whitespace"
|
|
|
|
|
'("foo" "" "bar")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "- "))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo - - bar")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Splits on leading non-whitespace separator"
|
|
|
|
|
'("" "foo")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "-"))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("-foo")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Does not split on trailing non-whitespace separator"
|
|
|
|
|
'("foo")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "-"))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("foo-")))))
|
2018-11-11 02:12:45 +00:00
|
|
|
|
|
|
|
|
|
(test-equal "Makes one field for single non-whitespace separator"
|
|
|
|
|
'("")
|
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-11-25 05:47:09 +00:00
|
|
|
|
(with-variables '(("IFS" . "-"))
|
|
|
|
|
(lambda ()
|
2021-04-19 16:16:17 +01:00
|
|
|
|
(expand-qword '("-")))))
|
2018-07-12 03:05:15 +01:00
|
|
|
|
|
|
|
|
|
(test-end)
|
2019-12-02 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
;; Local Variables:
|
|
|
|
|
;; eval: (put 'mock 'scheme-indent-function 1)
|
|
|
|
|
;; eval: (put 'with-mocked-files 'scheme-indent-function 1)
|
|
|
|
|
;; End:
|