Skip to content

Commit

Permalink
do not follow symlinks on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
gokcehan committed Aug 14, 2016
1 parent fac1c9e commit bc4c3c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
16 changes: 16 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ func (app *App) handleInp() {
for {
if gExitFlag {
log.Print("bye!")

if gLastDirPath != "" {
f, err := os.Create(gLastDirPath)
if err != nil {
log.Print(err)
}
defer f.Close()

dir := app.nav.currDir()

_, err = f.WriteString(dir.path)
if err != nil {
log.Print(err)
}
}

return
}
e := app.ui.getExpr()
Expand Down
21 changes: 2 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (

var (
gExitFlag bool
gLastDirPath string
gSelectionPath string
gSocketPath string
gLogPath string
Expand Down Expand Up @@ -62,7 +63,7 @@ func startServer() {

func main() {
serverMode := flag.Bool("server", false, "start server (automatic)")
lastDirPath := flag.String("last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
flag.StringVar(&gSelectionPath, "selection-path", "", "path to the file to write selected files on exit (to use as open file dialog)")

flag.Parse()
Expand All @@ -78,22 +79,4 @@ func main() {

client()
}

if *lastDirPath != "" {
f, err := os.Create(*lastDirPath)
if err != nil {
log.Print(err)
}
defer f.Close()

wd, err := os.Getwd()
if err != nil {
log.Print(err)
}

_, err = f.WriteString(wd)
if err != nil {
log.Print(err)
}
}
}

0 comments on commit bc4c3c1

Please sign in to comment.