diff --git a/gash/built-ins/read.scm b/gash/built-ins/read.scm index 5e916ac..8be2826 100644 --- a/gash/built-ins/read.scm +++ b/gash/built-ins/read.scm @@ -23,6 +23,7 @@ #:use-module (gash environment) #:use-module (ice-9 match) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-14) #:use-module (srfi srfi-26)) ;;; Commentary: @@ -84,6 +85,12 @@ field, while contiguous sequences of characters from the set (reverse! (cons field acc))))))))) (else '()))) +(define (right-pad lst n) + (let ((m (length lst))) + (if (< m n) + (append lst (make-list (- n m) "")) + lst))) + (define (main . args) (match-let* (((vars . get-line) (match args @@ -102,7 +109,7 @@ field, while contiguous sequences of characters from the set ;; XXX: Verify that VAR is a valid variable name. (setvar! var field)) vars - (append fields (circular-list ""))) + (right-pad fields (length vars))) (if (eof-object? delimiter) EXIT_FAILURE EXIT_SUCCESS)))