<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch release-2.6
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/e8e69d36258df9fc4c0a35eb0be7c3a16ffdb66d">https://github.com/macports/macports-base/commit/e8e69d36258df9fc4c0a35eb0be7c3a16ffdb66d</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit e8e69d36258df9fc4c0a35eb0be7c3a16ffdb66d
</span>Author: Ryan Schmidt <ryandesign@macports.org>
AuthorDate: Sat Jun 27 11:03:23 2020 -0500

<span style='display:block; white-space:pre;color:#404040;'>    Fix shellescape to work on Tiger
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Closes: https://trac.macports.org/ticket/56626
</span><span style='display:block; white-space:pre;color:#404040;'>    (cherry picked from commit 62e0767bd2f700243be8053db6e16994669e3def)
</span>---
 src/macports1.0/macports.tcl        | 18 +++++-------------
 src/macports1.0/tests/macports.test |  4 ++--
 2 files changed, 7 insertions(+), 15 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index dc31578e..7b5dd3c2 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -5,7 +5,7 @@
</span> # Copyright (c) 2004 - 2005 Paul Guyot, <pguyot@kallisys.net>.
 # Copyright (c) 2004 - 2006 Ole Guldberg Jensen <olegb@opendarwin.org>.
 # Copyright (c) 2004 - 2005 Robert Shaw <rshaw@opendarwin.org>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-# Copyright (c) 2004 - 2016 The MacPorts Project
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Copyright (c) 2004 - 2020 The MacPorts Project
</span> # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -5536,18 +5536,10 @@ proc macports::get_archive_sites_conf_values {} {
</span> # @param arg The argument that should be escaped for use in a POSIX shell
 # @return A quoted version of the argument
 proc macports::shellescape {arg} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    set mapping {}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # Replace each backslash by a double backslash. Apparently Bash treats Backslashes in single-quoted strings
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # differently depending on whether is was invoked as sh or bash: echo 'using \backslashes' preserves the backslash
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # in bash mode, but interprets it in sh mode. Since the `system' command uses sh, escape backslashes.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    lappend mapping "\\" "\\\\"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # Replace each single quote with a single quote (closing the currently open string), an escaped single quote \'
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # (additional backslash needed to escape the backslash in Tcl), and another single quote (opening a new quoted
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # string).
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    lappend mapping "'" "'\\''"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # Add a single quote at the start, escape all single quotes in the argument, and add a single quote at the end
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    return "'[string map $mapping $arg]'"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    # Put a bashslash in front of every character that is not safe. This
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    # may not be an exhaustive list of safe characters but it is allowed
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    # to put a backslash in front of safe characters too.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    return [regsub -all -- {[^A-Za-z0-9.:@%/+=_-]} $arg {\\&}]
</span> }
 
 ##
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/tests/macports.test b/src/macports1.0/tests/macports.test
</span><span style='display:block; white-space:pre;color:#808080;'>index b9400163..c395ccc0 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/tests/macports.test
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/tests/macports.test
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1037,10 +1037,10 @@ test shellescaping {
</span>     set first "yes"
     foreach test $shellescapeTests {
         if {$first eq "yes"} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            system "echo [macports::shellescape $test]  >$outputfile"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            system "printf '%s\n' [macports::shellescape $test]  >$outputfile"
</span>             set first "no"
         } else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            system "echo [macports::shellescape $test] >>$outputfile"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            system "printf '%s\n' [macports::shellescape $test] >>$outputfile"
</span>         }
     }
 
</pre><pre style='margin:0'>

</pre>