示例#1
0
文件: action.go 项目: sbinet/fubsy
func logFunctionCall(callable types.FuCallable, args types.ArgSource) {
	argstrings := make([]string, len(args.Args()))
	for i, arg := range args.Args() {
		argstrings[i] = arg.String()
	}
	log.Info("%s(%s)", callable.Name(), strings.Join(argstrings, ", "))
}
示例#2
0
文件: action.go 项目: sbinet/fubsy
func (self *CommandAction) Execute(rt *Runtime) []error {
	//fmt.Println(self.raw)

	var err error
	self.expanded, err = self.raw.ActionExpand(rt.Namespace(), nil)
	if err != nil {
		return []error{err}
	}
	log.Info("%s", self.expanded.ValueString())

	// Run commands with the shell because people expect redirection,
	// pipes, etc. to work from their build scripts. (And besides, all
	// we have is a string: Fubsy makes no effort to encourage
	// commands as lists. That just confuses people and causes excess
	// typing. And it's pointless on Windows, where command lists get
	// collapsed to a string and then parsed back into words by the
	// program being run.)
	// XXX can we mitigate security risks of using the shell?
	// XXX what about Windows?
	// XXX for parallel builds: gather stdout and stderr, accumulate
	// them in order but still distinguishing them, and dump them to
	// our stdout/stderr when the command finishes
	// XXX the error message doesn't say which command failed (and if
	// it did, it would probably say "/bin/sh", which is useless): can
	// we do better?
	cmd := exec.Command("/bin/sh", "-c", self.expanded.ValueString())
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err = cmd.Run()
	if err != nil {
		return []error{err}
	}
	return nil
}