Skip to content

Commit 5a2aede

Browse files
committed
don't mangle macros with spaces at the beginning
1 parent 2c3ef90 commit 5a2aede

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

netrc/examples/good.netrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macdef allput
99
put src/*
1010

1111
macdef allput2
12-
put src/*
12+
put src/*
1313
put src2/*
1414

1515
machine ray login demo password mypassword

netrc/netrc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func parse(r io.Reader, pos int) (*Netrc, error) {
230230

231231
if currentMacro != nil && bytes.Contains(rawb, []byte{'\n', '\n'}) {
232232
// if macro rawvalue + rawb would contain \n\n, then macro def is over
233-
currentMacro.value = strings.TrimSpace(string(currentMacro.rawvalue))
233+
currentMacro.value = string(bytes.TrimLeft(currentMacro.rawvalue, "\r\n"))
234234
nrc.macros[currentMacro.macroName] = currentMacro.value
235235
nrc.tokens = append(nrc.tokens, currentMacro)
236236
currentMacro = nil

netrc/netrc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var expectedMachines = []*Machine{
1919
}
2020
var expectedMacros = Macros{
2121
"allput": "put src/*",
22-
"allput2": "put src/*\nput src2/*",
22+
"allput2": " put src/*\nput src2/*",
2323
}
2424

2525
func eqMachine(a *Machine, b *Machine) bool {

0 commit comments

Comments
 (0)