commit:     f0ceaf3607b88982bad6bc9954d9e14f7b8f512c
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jun  4 03:24:27 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 12 07:06:42 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=f0ceaf36

Reposition the declaration of quote_args()

So as to maintain an alphabetical order.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 functions.sh | 106 +++++++++++++++++++++++++++++------------------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/functions.sh b/functions.sh
index a9af6b6..f440dab 100644
--- a/functions.sh
+++ b/functions.sh
@@ -539,6 +539,59 @@ parallel_run()
        ! rmdir -- "${statedir}" 2>/dev/null
 }
 
+#
+# Prints the positional parameters in a manner that approximates the behaviour
+# of the ${*@Q} expansion in bash. The output shall be POSIX sh compatible as 
of
+# Issue 8. This should probably be made to exist as a standalone awk script.
+#
+quote_args()
+{
+       awk -v q=\' -f - -- "$@" <<-'EOF'
+               BEGIN {
+                       argc = ARGC
+                       ARGC = 1
+                       for (arg_idx = 1; arg_idx < argc; arg_idx++) {
+                               arg = ARGV[arg_idx]
+                               if (arg !~ /[\001-\037\177]/) {
+                                       gsub(q, q "\\" q q, arg)
+                                       word = q arg q
+                               } else {
+                                       # Use $'' quoting per Issue 8
+                                       if (ord_by["\001"] == "") {
+                                               for (i = 1; i < 32; i++) {
+                                                       char = sprintf("%c", i)
+                                                       ord_by[char] = i
+                                               }
+                                               ord_by["\177"] = 127
+                                       }
+                                       word = "$'"
+                                       for (i = 1; i <= length(arg); i++) {
+                                               char = substr(arg, i, 1)
+                                               if (char == "\\") {
+                                                       word = word "\\\\"
+                                               } else if (char == q) {
+                                                       word = word "\\'"
+                                               } else {
+                                                       ord = ord_by[char]
+                                                       if (ord != "") {
+                                                               word = word 
"\\" sprintf("%03o", ord)
+                                                       } else {
+                                                               word = word char
+                                                       }
+                                               }
+                                       }
+                                       word = word q
+                               }
+                               line = line word
+                               if (arg_idx < argc - 1) {
+                                       line = line " "
+                               }
+                       }
+                       print line
+               }
+       EOF
+}
+
 #
 # Declare the vebegin, veerror, veindent, veinfo, veinfon, veoutdent and vewarn
 # functions. These differ from their non-v-prefixed counterparts in that they
@@ -839,59 +892,6 @@ _is_visible()
        ! case $1 in *[[:graph:]]*) false ;; esac
 }
 
-#
-# Prints the positional parameters in a manner that approximates the behaviour
-# of the ${*@Q} expansion in bash. The output shall be POSIX sh compatible as 
of
-# Issue 8. This should probably be made to exist as a standalone awk script.
-#
-quote_args()
-{
-       awk -v q=\' -f - -- "$@" <<-'EOF'
-               BEGIN {
-                       argc = ARGC
-                       ARGC = 1
-                       for (arg_idx = 1; arg_idx < argc; arg_idx++) {
-                               arg = ARGV[arg_idx]
-                               if (arg !~ /[\001-\037\177]/) {
-                                       gsub(q, q "\\" q q, arg)
-                                       word = q arg q
-                               } else {
-                                       # Use $'' quoting per Issue 8
-                                       if (ord_by["\001"] == "") {
-                                               for (i = 1; i < 32; i++) {
-                                                       char = sprintf("%c", i)
-                                                       ord_by[char] = i
-                                               }
-                                               ord_by["\177"] = 127
-                                       }
-                                       word = "$'"
-                                       for (i = 1; i <= length(arg); i++) {
-                                               char = substr(arg, i, 1)
-                                               if (char == "\\") {
-                                                       word = word "\\\\"
-                                               } else if (char == q) {
-                                                       word = word "\\'"
-                                               } else {
-                                                       ord = ord_by[char]
-                                                       if (ord != "") {
-                                                               word = word 
"\\" sprintf("%03o", ord)
-                                                       } else {
-                                                               word = word char
-                                                       }
-                                               }
-                                       }
-                                       word = word q
-                               }
-                               line = line word
-                               if (arg_idx < argc - 1) {
-                                       line = line " "
-                               }
-                       }
-                       print line
-               }
-       EOF
-}
-
 #
 # See the definitions of oldest() and newest().
 #

Reply via email to