about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--common/init15
1 files changed, 10 insertions, 5 deletions
diff --git a/common/init b/common/init
index 35662e2..4298e68 100644
--- a/common/init
+++ b/common/init
@@ -31,11 +31,14 @@ die() {
     exit 1
 }
 quotify() {
-    input="$1"
-
-    # The quotes are actually fine like they are.
-    # shellcheck disable=SC1003
-    echo "$input" | awk '{ gsub(/'\''/, "'\''\\'\'''\''", $0); print("'\''" $0 "'\''"); }'
+    python -c "
+import sys
+if len(sys.argv) > 1:
+    text =''.join(sys.argv[1:])
+else:
+    text = sys.stdin.read()
+quoted_text = text.replace(\"'\", \"'\\\\''\")
+print(f\"'{quoted_text}'\", end='')" "$@"
 }
 
 # Prompt the user for a specific variable.
@@ -80,6 +83,8 @@ require mv
 require sed
 require chmod
 
+require python
+
 # necessary meta data
 prompt APPLICATION_NAME "The name of the application" "$(basename "$PWD")"
 prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')"