X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=blobdiff_plain;f=do.go;h=516b1438c28d5751d477f645c57c45aae47f0956;hp=4ed91ddaa929c09112fb2c6021ab47b0c3307a45;hb=314f58ec690c7321535d6718e8d3a0ecb4cac019;hpb=3e54a0b7b57f437247bb2d7b3ee15fdbdc6efff7 diff --git a/do.go b/do.go index 4ed91dd..516b143 100644 --- a/do.go +++ b/do.go @@ -1,6 +1,6 @@ /* -goredo -- redo implementation on pure Go -Copyright (C) 2020 Sergey Matveev +goredo -- djb's redo implementation on pure Go +Copyright (C) 2020-2021 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,6 +49,7 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) { if exists { return doFile, 0, nil } + doFileOrig := doFile levels := []string{} extsOrig := strings.Split(tgt, ".")[1:] dirAbsPrev := "" @@ -59,6 +60,19 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) { doFile = strings.Join(append( []string{"default"}, append(exts, "do")..., ), ".") + if len(levels) > 0 || doFile != doFileOrig { + exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile)) + if err != nil { + return "", 0, err + } + if exists { + return doFile, len(levels), nil + } + } + exts = exts[1:] + } + doFile = "default.do" + if len(levels) > 0 || doFile != doFileOrig { exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile)) if err != nil { return "", 0, err @@ -66,18 +80,9 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) { if exists { return doFile, len(levels), nil } - exts = exts[1:] - } - doFile = "default.do" - exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile)) - if err != nil { - return "", 0, err - } - if exists { - return doFile, len(levels), nil } levels = append(levels, "..") - dirAbs, err := filepath.Abs(updir) + dirAbs, err := filepath.Abs(path.Join(cwd, updir)) if err != nil { panic(err) }