Skip to content

Incorrect escape of single quote  #15

@bawolk

Description

@bawolk

In bash, a single-quoted string cannot contain a single quote even if it is escaped. However, single quotes can be included in a string of the form $'string' if they are escaped. I have an executable, hsp, that expects a single-quoted string. The following command works fine at the bash prompt and produces the expected output foo:

$ echo $'foo\nbar' | hsp $'\'o\' `elem` p'
foo

However the following test fails:

hsp $'\'o\' `elem` p'
<<<
foo
bar
>>>
foo
>>>= 0

Using debug I get the following:

command was: "hsp $'\\'o\\' `elem` p'"
stdout was : ""
stderr was : "/bin/sh: 1: Syntax error: Unterminated quoted string\n"
exit was   : "2"

It looks like shelltestrunner is double escaping the single-quote, thereby creating a syntax error, when it should leave unchanged the single escape of the single-quote inside the form $'string".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions