Skip to content

Commit

Permalink
fix #29: fix stat() error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas von Dein committed Dec 13, 2024
1 parent 4dc87ac commit 8098ccf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

const DefaultSeparator string = `(\s\s+|\t)`
const Version string = "v1.2.2"
const Version string = "v1.2.3"
const MAXPARTS = 2

var DefaultLoadPath = os.Getenv("HOME") + "/.config/tablizer/lisp"
Expand Down Expand Up @@ -328,7 +328,16 @@ func (conf *Config) PreparePattern(pattern string) error {
func (conf *Config) ParseConfigfile() error {
path, err := os.Stat(conf.Configfile)

if os.IsNotExist(err) || path.IsDir() {
if err != nil {
if os.IsNotExist(err) {
// ignore non-existent files
return nil
}

return fmt.Errorf("failed to stat config file: %w", err)
}

if path.IsDir() {
// ignore non-existent or dirs
return nil
}
Expand Down
10 changes: 8 additions & 2 deletions lib/lisp.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ func SetupLisp(conf *cfg.Config) error {
// iterate over load-path and evaluate all *.zy files there, if any
// we ignore if load-path does not exist, which is the default anyway
path, err := os.Stat(conf.LispLoadPath)
if os.IsNotExist(err) {
return nil

if err != nil {
if os.IsNotExist(err) {
// ignore non-existent files
return nil
}

return fmt.Errorf("failed to stat path: %w", err)
}

// init global hooks
Expand Down

0 comments on commit 8098ccf

Please sign in to comment.