diff --git a/scsh/glob.scm b/scsh/glob.scm index 4927f79..83de27c 100644 --- a/scsh/glob.scm +++ b/scsh/glob.scm @@ -129,21 +129,17 @@ ;;; Is the glob pattern free of *'s, ?'s and [...]'s? (define (constant-glob? pattern) (let ((patlen (string-length pattern))) - (let lp ((i 0) - (escape? #f)) ; Was last char an escape char (backslash)? - (if (= i patlen) - - (if escape? - (error "Ill-formed glob pattern" pattern) - #t) - + (let lp ((i 0)) + (or (= i patlen) (let ((next-i (+ i 1))) - (if escape? (lp next-i #f) - (case (string-ref pattern i) - ((#\* #\? #\[) #f) - ((#\\) (lp next-i #t)) - (else (lp next-i #f))) - (lp next-i #f))))))) + (case (string-ref pattern i) + ((#\\) ; Escape char + (if (= next-i patlen) + (error "Ill-formed glob pattern -- ends in backslash" + pattern) + (lp (+ next-i 1)))) + ((#\* #\? #\[) #f) + (else (lp next-i)))))))) ;;; Make an effort to get the files in the putative directory PATH.