diff --git a/Makefile.am b/Makefile.am index 3dcc4ce..97b7c81 100644 --- a/Makefile.am +++ b/Makefile.am @@ -147,6 +147,7 @@ FULL_TESTS = \ tests/signals.org \ tests/temporary-assignments.org \ tests/variable-and.org \ + tests/variable-operators.org \ tests/variable-or.org \ tests/variable-patterns.org \ tests/variable-words.org \ diff --git a/gash/word.scm b/gash/word.scm index 7d6f8ac..e53a843 100644 --- a/gash/word.scm +++ b/gash/word.scm @@ -278,9 +278,15 @@ and arithmetic substitions." (setvar! name new-value) new-value)))) ((' name message) - (error (format #f "Not implemented: ~s" word))) + (or (parameter-ref name) + (let ((message* (expand-word message #:output 'string))) + (throw 'shell-error (format #f "~a: ~a" name message*))))) ((' name message) - (error (format #f "Not implemented: ~s" word))) + (let ((value (parameter-ref name))) + (if (string-not-null? value) + value + (let ((message* (expand-word message #:output 'string))) + (throw 'shell-error (format #f "~a: ~a" name message*)))))) ((' name value) (if (string-not-null? (parameter-ref name)) (word->qword (or value "")) diff --git a/tests/variable-operators.org b/tests/variable-operators.org new file mode 100644 index 0000000..11e5559 --- /dev/null +++ b/tests/variable-operators.org @@ -0,0 +1,26 @@ +;;; Gash -- Guile As SHell +;;; Copyright © 2019 Timothy Sample +;;; +;;; This file is part of Gash. +;;; +;;; Gash is free software: you can redistribute it and/or modify +;;; 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. +;;; +;;; Gash is distributed in the hope that it will be useful, +;;; 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 +;;; along with Gash. If not, see . + +* Errors on failed asserting reference +:script: +#+begin_src sh + echo ${x?not set} + echo not shown +#+end_src +:status: 1 +:stdout: ""