~ chicken-core (chicken-5) 1cd587adf8ae40b9e8e779791796ad6dfea209f6


commit 1cd587adf8ae40b9e8e779791796ad6dfea209f6
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Oct 21 16:36:07 2022 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Sun Oct 23 18:00:14 2022 +0200

    try to improve automated quoting/escaping in csc
    
    See also #1302
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/NEWS b/NEWS
index 980ec9b0..e59c04a2 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@
 - Tools
   - The -R option for csi and csc now accepts list-notation like
     e.g. (srfi 1).  Fixes #1809, reported by Wolfgang Corcoran-Mathe.
+  - Fix shell quotation in options passed from csc to other tools.
+    Fixes #1302, reported by Xin Wang.
 
 - Build system
   - Default "cc" on BSD systems for building CHICKEN to avoid ABI problems
diff --git a/csc.scm b/csc.scm
index 921c7841..11e17941 100644
--- a/csc.scm
+++ b/csc.scm
@@ -1056,23 +1056,6 @@ EOF
 
 ;;; Helper procedures:
 
-(define-constant +hairy-chars+ '(#\\ #\#))
-
-(define (cleanup s)
-  (let* ((q #f)
-	 (s (list->string
-	     (let fold ([s (string->list s)])
-	       (if (null? s) 
-		   '()
-		   (let ([c (car s)])
-		     (cond ((memq c +hairy-chars+) (cons* #\\ c (fold (cdr s))))
-			   (else
-			    (when (char-whitespace? c) (set! q #t))
-			    (cons c (fold (cdr s))) ) ) ) ) ) ) ) )
-    (if q 
-	(string-append "\"" (string-translate* s '(("\"" . "\\\""))) "\"")
-	s) ) )
-
 ;; Simpler replacement for SRFI-13's string-any
 (define (string-any criteria s)
   (let ((end (string-length s)))
@@ -1083,13 +1066,7 @@ EOF
             (or (criteria c)
                 (lp i1)))))))
 
-(define (quote-option x)
-  (cond ((string-any (cut char=? #\" <>) x) x)
-	((string-any (lambda (c)
-		       (or (char-whitespace? c) (memq c +hairy-chars+)) )
-		     x)
-	 (cleanup x))
-	(else x) ))
+(define quote-option qs)
 
 (define last-exit-code #f)
 
diff --git a/manual/Acknowledgements b/manual/Acknowledgements
index 4a756150..b9e81398 100644
--- a/manual/Acknowledgements
+++ b/manual/Acknowledgements
@@ -52,8 +52,8 @@ Robert Skeels, Sandra Snan, Jason Songhurst, Clifford Stein, David Steiner,
 Thu, Christian Tismer, Andre van Tonder, John Tobey, Henrik Tramberend,
 Vladimir Tsichevsky, James Ursetto, Neil van Dyke, Sam Varner,
 Taylor Venable, Sander Vesik, Jaques Vidrine, Panagiotis Vossos,
-Shawn Wagner, Peter Wang, Ed Watkeys, Brad Watson, Thomas Weidner, Göran
-Weinholt, Matthew Welland, Drake Wilson, Jörg Wittenberger, Peter
+Shawn Wagner, Peter Wang, Xin Wang, Ed Watkeys, Brad Watson, Thomas Weidner,
+Göran Weinholt, Matthew Welland, Drake Wilson, Jörg Wittenberger, Peter
 Wright, Mark Wutka, Adam Young, Richard Zidlicky, Houman Zolfaghari and
 Florian Zumbiehl for bug-fixes, tips and suggestions.
 
Trap