in plugin/step/bundle/extcommand.go [56:82]
func commandForPath(path string, ctx context.Context) *exec.Cmd {
switch filepath.Ext(path) {
case ".ps1":
return exec.CommandContext(ctx, "powershell.exe", "-ExecutionPolicy", "Bypass", "-File", path)
case ".bat", ".cmd":
return exec.CommandContext(ctx, "cmd", "/c", path)
case ".rb":
return exec.CommandContext(ctx, chefRuby(), path)
case ".sh":
fi, err := os.Lstat(path)
if err != nil {
return nil
}
mode := fi.Mode().Perm()
// If the script is executable, execute it directly
if mode&0111 == 0111 {
return exec.CommandContext(ctx, path)
}
return exec.CommandContext(ctx, "sh", path)
case ".bash":
return exec.CommandContext(ctx, "bash", path)
default:
return nil
}
}