Skip to content

Commit

Permalink
(maint) Make context checkFile fn expand tildes
Browse files Browse the repository at this point in the history
  • Loading branch information
ploubser committed Oct 9, 2024
1 parent 4da881f commit 8787628
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cli/context_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"os"
"os/exec"
"os/user"
"sort"
"strings"
"text/template"
Expand Down Expand Up @@ -454,6 +455,14 @@ func (c *ctxCommand) showCommand(_ *fisk.ParseContext) error {
if strings.HasPrefix(file, "op://") {
return color.CyanString("1Password")
}
if file[0] == '~' {
usr, err := user.Current()
if err != nil {
return color.RedString("ERROR")
}
file = strings.Replace(file, "~", usr.HomeDir, 1)
}

ok, err := fileAccessible(file)
if !ok || err != nil {
c.validateErrors++
Expand Down

0 comments on commit 8787628

Please sign in to comment.