From e817606edf3876c9754f1d1817b46eddd0bca666 Mon Sep 17 00:00:00 2001 From: udhos Date: Thu, 25 Apr 2019 19:02:49 -0300 Subject: [PATCH] Fix file glob. --- applets/shell/run.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/applets/shell/run.go b/applets/shell/run.go index 3a3b9b6..6253263 100644 --- a/applets/shell/run.go +++ b/applets/shell/run.go @@ -149,24 +149,38 @@ func expand(params []string) []string { // 1. expand env vars + //fmt.Printf("== %d %v\n", len(params), params) + var exp1 []string for _, p := range params { exp1 = append(exp1, os.ExpandEnv(p)) } + //fmt.Printf("$$ %d %v\n", len(exp1), exp1) + // 2. expand file globs var exp2 []string for _, p := range exp1 { + if p == "" { + exp2 = append(exp2, p) + continue + } g, errGlob := filepath.Glob(p) if errGlob != nil { fmt.Printf("shell: glob: %v", errGlob) - exp2 = append(exp2, p) // keep unexpanded + exp2 = append(exp2, p) + continue + } + if len(g) < 1 { + exp2 = append(exp2, p) continue } exp2 = append(exp2, g...) } + //fmt.Printf("** %d %v\n", len(exp2), exp2) + return exp2 }