summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Sample <samplet@ngyro.com>2021-04-16 21:57:40 -0400
committerTimothy Sample <samplet@ngyro.com>2021-04-19 15:09:16 -0400
commit2bce1ea07bce8104f85c28ed74785745a46b5403 (patch)
tree15d260b8d209f7e64ad4b1f6d784076bbc6c6a2f
parent1e88c314d6662c41db7c496c8912c0e9c4f5f14f (diff)
Add an 'expand-qword' procedure.
* gash/word.scm (expand-qword): New procedure. (expand-word): Rewrite in terms of 'expand-qword'.
-rw-r--r--gash/word.scm17
1 files changed, 10 insertions, 7 deletions
diff --git a/gash/word.scm b/gash/word.scm
index 894bc15..2bac8d5 100644
--- a/gash/word.scm
+++ b/gash/word.scm
@@ -24,6 +24,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (eval-cmd-sub
+ expand-qword
expand-word))
;;; Commentary:
@@ -336,13 +337,10 @@ and arithmetic substitions."
(number->string (string-length (parameter-ref name ""))))
(_ (map word->qword word))))
-(define* (expand-word word #:key (output 'fields) (rhs-tildes? #f))
- "Expand @var{word} into a list of fields."
- ;; The value of '$IFS' may depend on side-effects performed during
- ;; 'word->qword', so use 'let*' here.
- (let* ((qword (word->qword word))
- (ifs (getvar "IFS" (string #\space #\tab #\newline)))
- (pwd (getvar "PWD")))
+(define* (expand-qword qword #:key (output 'fields) (rhs-tildes? #f))
+ "Expand @var{qword} into a list of fields."
+ (let ((ifs (getvar "IFS" (string #\space #\tab #\newline)))
+ (pwd (getvar "PWD")))
(match output
('fields (if pwd
(append-map (cut expand-pathnames <> pwd ifs)
@@ -351,3 +349,8 @@ and arithmetic substitions."
(split-fields qword ifs))))
('string (remove-quotes qword ifs))
('pattern (qword->pattern qword ifs)))))
+
+(define* (expand-word word #:key (output 'fields) (rhs-tildes? #f))
+ "Expand @var{word} into a list of fields."
+ (let ((qword (word->qword word)))
+ (expand-qword qword #:output output #:rhs-tildes? rhs-tildes?)))