-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
This line doesn't seem to properly escapes single quotes using bash as a shell: https://github.com/fabric/patchwork/blob/master/patchwork/files.py#L130, possibly because bash needs a $'...\'...'
(https://wiki.bash-hackers.org/scripting/bashchanges#quoting_expansions_substitutions_and_related).
patchwork.files.append(c, filename="/etc/postgresql/10/main/postgresql.conf", text="listen_addresses = '*'", escape=True)
# line that is added:
# listen_addresses = \*\\
This script shows the problem that i am experiencing:
import subprocess
def run(script):
process = subprocess.run(
["bash", "-s"], capture_output=True, input=script.encode("ascii"))
stderr = process.stderr.decode("ascii")
print(stderr, end="")
stdout = process.stdout.decode("ascii")
print(stdout, end="")
line = "listen_addresses = '*'"
escaped = line.replace("'", r"'\\''")
script = f"echo '{escaped}'"
run(script)
# listen_addresses = \*\\
line = "listen_addresses = '*'"
escaped = "$'" + line.replace("'", r"\'") + "'"
script = f"echo {escaped}"
run(script)
# listen_addresses = '*'
Thank you for Fabric! :)
Metadata
Metadata
Assignees
Labels
No labels