Fix home ~ resolution
This commit is contained in:
@@ -356,8 +356,14 @@ func loadFromReference(fromFile, currentFile, workdir string, visited map[string
|
||||
|
||||
// expandGlobs expands glob patterns in a single instruction
|
||||
func expandGlobs(instr LinkInstruction, filename, workdir string) ([]LinkInstruction, error) {
|
||||
LogSource("Expanding pattern source %s in YAML file %s", instr.Source, filename)
|
||||
newlinks, err := ExpandPattern(instr.Source, workdir, instr.Target)
|
||||
// Convert home directory (~) before expanding pattern
|
||||
convertedSource, err := ConvertHome(instr.Source)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting home directory in source %s: %w", instr.Source, err)
|
||||
}
|
||||
|
||||
LogSource("Expanding pattern source %s in YAML file %s", convertedSource, filename)
|
||||
newlinks, err := ExpandPattern(convertedSource, workdir, instr.Target)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -434,6 +440,11 @@ func parseYAMLFileRecursive(filename, workdir string, visited map[string]bool) (
|
||||
}
|
||||
|
||||
func ExpandPattern(source, workdir, target string) (links []LinkInstruction, err error) {
|
||||
// Convert home directory (~) before splitting pattern
|
||||
source, err = ConvertHome(source)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting home directory in source %s: %w", source, err)
|
||||
}
|
||||
static, pattern := doublestar.SplitPattern(source)
|
||||
if static == "" || static == "." {
|
||||
static = workdir
|
||||
|
Reference in New Issue
Block a user