Skip to content

Commit f3bbb6f

Browse files
authored
Merge pull request mattn#53 from ndeloof/master
parse `\t` as TAB, not escaped `t`
2 parents 973b9d5 + f6737fe commit f3bbb6f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

shellwords.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ loop:
136136
for _, r := range line {
137137
i++
138138
if escaped {
139+
if r == 't' {
140+
r = '\t'
141+
}
142+
if r == 'n' {
143+
r = '\n'
144+
}
139145
buf += string(r)
140146
escaped = false
141147
got = argSingle

shellwords_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var testcases = []struct {
3838
{`foo "" bar ''`, []string{`foo`, ``, `bar`, ``}},
3939
{`foo \\`, []string{`foo`, `\`}},
4040
{`foo \& bar`, []string{`foo`, `&`, `bar`}},
41+
{`sh -c "printf 'Hello\tworld\n'"`, []string{`sh`, `-c`, "printf 'Hello\tworld\n'"}},
4142
}
4243

4344
func TestSimple(t *testing.T) {

0 commit comments

Comments
 (0)