Fix home ~ resolution

This commit is contained in:
2025-10-19 17:45:15 +02:00
parent ff76a5399c
commit dbd736ae81
3 changed files with 63 additions and 2 deletions

View File

@@ -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