please icon indicating copy to clipboard operation
please copied to clipboard

f-string formatting: braces not correctly escaped

Open thisguycodes opened this issue 7 years ago • 0 comments

With python f-strings, you state literal braces by doubling them:

print(f"{{word}}")

produces:

{word}

Please correctly does not attempt to interpret word as a variable, however it instead produces:

{{word}}

Here is the claim stated as a please test:

sh_cmd(
    name="f_string-braces_escape.sh",
    shell="/bin/bash",
    cmd=[
        f'F_STRING="{{word}}"',
        'RAW_STRING="{word}"',
        '[ "\\\$F_STRING" = "\\\$RAW_STRING" ]',
    ],
)

sh_test(
    name="f_string-braces_escape",
    src=":f_string-braces_escape.sh",
)

thisguycodes avatar Aug 05 '19 15:08 thisguycodes