mirror of
https://github.com/hashicorp/packer.git
synced 2026-05-28 04:35:38 -04:00
fix: take only first line from the script
This commit is contained in:
parent
c1db3bf8fa
commit
e8c2f7b3b0
1 changed files with 6 additions and 1 deletions
|
|
@ -113,7 +113,12 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
|||
|
||||
if p.config.InlineShebang == "" {
|
||||
if p.config.Inline != nil && len(p.config.Inline) > 0 && strings.HasPrefix(p.config.Inline[0], "#!") {
|
||||
p.config.InlineShebang = strings.TrimPrefix(p.config.Inline[0], "#!")
|
||||
newLineIndex := strings.Index(p.config.Inline[0], "\n")
|
||||
if newLineIndex == -1 {
|
||||
newLineIndex = len(p.config.Inline[0])
|
||||
}
|
||||
firstLine := strings.TrimRight(p.config.Inline[0][:newLineIndex], "\r")
|
||||
p.config.InlineShebang = strings.TrimPrefix(firstLine, "#!")
|
||||
} else {
|
||||
p.config.InlineShebang = "/bin/sh -e"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue