X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=main.go;h=b5618e649916efac50dc6ca0d6668a330422f80a;hb=6b1228a8f2c83bf1f7c74fe6405a0bf84f885896;hp=2e0778b0831c5a913a39e2c2e371f377c5010cca;hpb=1b925e709be6ccf17a8339be69953f5843b78532;p=goredo.git diff --git a/main.go b/main.go index 2e0778b..b5618e6 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,6 @@ along with this program. If not, see . package main import ( - "bufio" "crypto/rand" "flag" "fmt" @@ -29,6 +28,7 @@ import ( "path" "path/filepath" "strconv" + "strings" "go.cypherpunks.ru/recfile" "golang.org/x/sys/unix" @@ -91,7 +91,6 @@ func main() { log.Println(err) } } - fmt.Println("not creating optional:", os.Args[0], "<- tai64nlocal") os.Exit(rc) } log.SetFlags(0) @@ -106,7 +105,9 @@ func main() { NoSync = os.Getenv(EnvNoSync) == "1" TopDir = os.Getenv(EnvTopDir) - if TopDir != "" { + if TopDir == "" { + TopDir = "/" + } else { TopDir, err = filepath.Abs(TopDir) if err != nil { panic(err) @@ -144,6 +145,9 @@ func main() { MyPid = os.Getpid() } var traced bool + if *flagTraceAll { + mustSetenv(EnvTrace, "1") + } if *flagTrace { traced = true } else { @@ -250,9 +254,8 @@ CmdSwitch: break } os.Remove(fdTmp.Name()) - var doFile string cwd, tgt := cwdAndTgt(tgts[0]) - doFile, _, err = findDo(fdTmp, cwd, tgt) + doFile, upLevels, err := findDo(fdTmp, cwd, tgt) if err != nil { break } @@ -271,11 +274,11 @@ CmdSwitch: } fmt.Println(cwdMustRel(cwd, m["Target"])) } - ok = doFile != "" - case "tai64nlocal": - bw := bufio.NewWriter(os.Stdout) - err = tai64nLocal(bw, os.Stdin) - bw.Flush() + if doFile == "" { + ok = false + } else { + fmt.Println(path.Join(strings.Repeat("..", upLevels), doFile)) + } default: log.Fatalln("unknown command", cmdName) }