"path"
"path/filepath"
"strconv"
- "strings"
"go.cypherpunks.ru/recfile"
)
}
os.Remove(fdTmp.Name())
cwd, tgt := cwdAndTgt(tgts[0])
- cwdRel := cwdMustRel(cwd)
doFile, upLevels, err := findDo(fdTmp, cwd, tgt)
if err != nil {
break
if doFile == "" {
ok = false
} else {
- fmt.Println(path.Join(cwdRel, strings.Repeat("..", upLevels), doFile))
+ p := make([]string, 0, upLevels+2)
+ p = append(p, cwd)
+ for i := 0; i < upLevels; i++ {
+ p = append(p, "..")
+ }
+ p = append(p, doFile)
+ rel, err := filepath.Rel(Cwd, path.Join(p...))
+ if err != nil {
+ panic(err)
+ }
+ fmt.Println(rel)
}
default:
log.Fatalln("unknown command", cmdName)