fix #29: fix stat() error checking

This commit is contained in:
2024-12-13 10:35:56 +01:00
parent 4dc87ac22e
commit 8098ccf000
2 changed files with 19 additions and 4 deletions

View File

@@ -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"
@@ -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
}

View File

@@ -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