Skip to content

ANSI-C quotes applied to strings without ANSI-C escape sequences #8

@GeorgeHahn

Description

@GeorgeHahn

Hi, thanks for the great library!

I've noticed that some strings are unnecessarily quoted for ANSI-C escape sequences. This seems to happen on strings that contain an equal sign. For example, the string --arg=var will be quoted as $'--arg=var'. This is valid and doesn't cause any issues, but it does appear to be unnecessary.

I wasn't familiar with this style of quoting. It is covered in the bash docs here:

3.1.2.4 ANSI-C Quoting

Character sequences of the form $’string’ are treated as a special kind of single quotes. The sequence expands to string, with backslash-escaped characters in string replaced as specified by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows:

\a
alert (bell)

\b
backspace
...
The expanded result is single-quoted, as if the dollar sign had not been present.

(source)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions