package core import ( "os/exec" "regexp" "strings" ) var ( sh = regexp.MustCompile("\\{([^\\}]+)\\}") ) func Process(source string) string { source = sh.ReplaceAllStringFunc(source, func(match string) string { cmd := sh.FindStringSubmatch(match)[1] args := strings.Fields(cmd) shellArgs := []string{"-c", strings.Join(args, " ")} output, err := exec.Command("sh", shellArgs...).CombinedOutput() if err != nil { return err.Error() } return strings.Trim(string(output), "\n") }) return source }