ref: cbc4dbd38efbc9e123a2f30df8163fcdf5f22a3b
parent: 23bf90a915a0065fe463b2365fea84c273e4ad49
author: Matthew Flatt <mflatt@racket-lang.org>
date: Tue Oct 17 03:58:58 CDT 2023
Zuo: further improve and document `MAKEFLAGS` handling
--- a/lib/zuo/dry-run.zuo
+++ b/lib/zuo/dry-run.zuo
@@ -34,20 +34,21 @@
(string<? "z" (substring s i (+ i 1))))
(or (string<? (substring s i (+ i 1)) "A")
(string<? "Z" (substring s i (+ i 1)))))
- ;; doesn't look like single-letter flags
- #f]
+ ;; doesn't look like single-letter flags, so
+ ;; look for "-n", "-t", or "-q"
+ (let loop ([l l] [mode #f])
+ (cond
+ [(null? l)
+ (no-touch mode)]
+ [(member (car l) '("-n" "--just-print" "--dry-run" "--recon"))
+ (loop (cdr l) (new-mode mode 'dry-run))]
+ [(member (car l) '("-q" "--question"))
+ (loop (cdr l) (new-mode mode 'question))]
+ [(member (car l) '("-t" "--touch"))
+ (loop (cdr l) (new-mode mode 'touch))]
+ [(equal? "--" (car l))
+ (loop '() mode)]
+ [else
+ (loop (cdr l) mode)]))]
[else
- (loop (+ i 1) mode)])))
- ;; Otherwise, look for "-n", "-t", and "-q"
- (let loop ([l l] [mode #f])
- (cond
- [(null? l)
- (no-touch mode)]
- [(equal? "-n" (car l))
- (loop (cdr l) (new-mode mode 'dry-run))]
- [(equal? "-q" (car l))
- (loop (cdr l) (new-mode mode 'question))]
- [(equal? "-t" (car l))
- (loop (cdr l) (new-mode mode 'touch))]
- [else
- (loop (cdr l) mode)])))))))
+ (loop (+ i 1) mode)]))))))))
--- a/zuo-doc/zuo-lib.scrbl
+++ b/zuo-doc/zuo-lib.scrbl
@@ -407,4 +407,12 @@
a @Flag{t} flag triggers an error instead of a non-@racket[#f] value.
Conflicting options also trigger an error.
+The @envvar{MAKEFLAGS} environment variable is parsed into arguments
+using @racket[shell->strings]. If the first argument has only ASCII
+letters (lowercase or uppercase), then it is treated as a set of
+single-character flags. Otherwise, the argument list is scanned for
+@racket["-n"], @racket["--just-print"], @racket["--dry-run"],
+@racket["--recon"], @racket["-q"], @racket["--question"], @racket["-t"],
+or @racket["--touch"] stopping at any @racket["--"].
+
}