Summary
RFC 0006 defines repr_sh by reference to Python's shlex.quote and repr_py by reference
to Python's repr. Neither output matches for inputs containing a single quote:
Input "it's" |
Named Python function produces |
Implementation produces |
repr_sh |
'it'"'"'s' (shlex.quote) |
"it's" |
repr_py |
"it's" (repr switches quote style) |
'it\'s' (always single-quote, escapes) |
repr_sh's output here is still shell-safe — this is a conformance/portability question
rather than a safety one: two implementations both "following shlex.quote" will embed
different bytes into command lines, which matters the moment output is compared, cached, or
hashed.
Versions
openjd-model 0.11.1 and 0.11.2 from PyPI
openjd-rs main at 1a89f3a — still reproduces
Reproduction
import shlex
from openjd.expr import parse_expression
r = parse_expression("repr_sh(\"it's\")").evaluate_with_metrics()
print(str(r.value), "vs", shlex.quote("it's"))
r = parse_expression("repr_py(\"it's\")").evaluate_with_metrics()
print(str(r.value), "vs", repr("it's"))
Suggested resolution
Either match the named functions byte-for-byte, or reword the spec to name the property
(shell-safe quoting; Python-literal round-tripping) rather than the function. Happy to file
against the spec instead if that's the preferred fix.
Summary
RFC 0006 defines
repr_shby reference to Python'sshlex.quoteandrepr_pyby referenceto Python's
repr. Neither output matches for inputs containing a single quote:"it's"repr_sh'it'"'"'s'(shlex.quote)"it's"repr_py"it's"(reprswitches quote style)'it\'s'(always single-quote, escapes)repr_sh's output here is still shell-safe — this is a conformance/portability questionrather than a safety one: two implementations both "following
shlex.quote" will embeddifferent bytes into command lines, which matters the moment output is compared, cached, or
hashed.
Versions
openjd-model0.11.1 and 0.11.2 from PyPIopenjd-rsmainat1a89f3a— still reproducesReproduction
Suggested resolution
Either match the named functions byte-for-byte, or reword the spec to name the property
(shell-safe quoting; Python-literal round-tripping) rather than the function. Happy to file
against the spec instead if that's the preferred fix.