More work on macros
This commit is contained in:
parent
4fc1dc0e9d
commit
2a10a02784
17
command.go
17
command.go
@ -38,12 +38,10 @@ type macro struct {
|
||||
func processCmd(params []string, dir string, conf *config, flags int) error {
|
||||
args := appendExpEnv(nil, params)
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("command element is invalid")
|
||||
return fmt.Errorf("invalid command statement")
|
||||
}
|
||||
|
||||
cmdName := args[0]
|
||||
var cmdArgs []string
|
||||
|
||||
if strings.HasPrefix(cmdName, "@") {
|
||||
macroName := strings.TrimPrefix(cmdName, "@")
|
||||
|
||||
@ -52,16 +50,21 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
|
||||
return fmt.Errorf("macro not found %s", macroName)
|
||||
}
|
||||
|
||||
cmdArgs = appendExpEnv(cmdArgs, m.Prefix)
|
||||
margs := appendExpEnv(nil, m.Prefix)
|
||||
if len(args) > 1 {
|
||||
cmdArgs = appendExpEnv(cmdArgs, args[1:])
|
||||
margs = appendExpEnv(margs, args[1:])
|
||||
}
|
||||
cmdArgs = appendExpEnv(cmdArgs, m.Suffix)
|
||||
margs = appendExpEnv(margs, m.Suffix)
|
||||
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("using macro %s", macroName)
|
||||
}
|
||||
} else if len(args) > 1 {
|
||||
|
||||
return processCmd(margs, dir, conf, flags)
|
||||
}
|
||||
|
||||
var cmdArgs []string
|
||||
if len(args) > 1 {
|
||||
cmdArgs = args[1:]
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ func processEnv(env []string, flags int) error {
|
||||
var value string
|
||||
switch {
|
||||
case len(args) == 0:
|
||||
return fmt.Errorf("enviornment element is invalid")
|
||||
return fmt.Errorf("invalid environment statement")
|
||||
case len(args) == 1:
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("unsetting variable %s", args[0])
|
||||
|
2
link.go
2
link.go
@ -73,7 +73,7 @@ func createPath(loc string, flags int, mode os.FileMode) error {
|
||||
func parseLink(params []string) (srcPath, dstPath string, mode os.FileMode, err error) {
|
||||
length := len(params)
|
||||
if length < 1 || length > 3 {
|
||||
err = fmt.Errorf("link element is invalid")
|
||||
err = fmt.Errorf("invalid link statement")
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user