func writeTempScript()

in main/cmds.go [257:285]


func writeTempScript(script, dir string, skipDosToUnix bool) (string, string, error) {
	if len(script) > maxScriptSize {
		return "", "", fmt.Errorf("The script's length (%d) exceeded the maximum allowed length of %d!", len(script), maxScriptSize)
	}

	s, info, err := decodeScript(script)
	if err != nil {
		return "", "", err
	}

	cmd := fmt.Sprintf("%s/script.sh", dir)
	f, err := os.OpenFile(cmd, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0500)
	if err != nil {
		return "", "", errors.Wrap(err, "failed to write script.sh")
	}

	f.WriteString(s)
	f.Close()

	dos2unix := 1
	if skipDosToUnix == false {
		err = postProcessFile(cmd)
		if err != nil {
			return "", "", errors.Wrap(err, "failed to post-process script.sh")
		}
		dos2unix = 0
	}
	return cmd, fmt.Sprintf("%s;dos2unix=%d", info, dos2unix), nil
}