mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 12:31:06 +01:00
fix #29: fix stat() error checking
This commit is contained in:
@@ -29,7 +29,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const DefaultSeparator string = `(\s\s+|\t)`
|
const DefaultSeparator string = `(\s\s+|\t)`
|
||||||
const Version string = "v1.2.2"
|
const Version string = "v1.2.3"
|
||||||
const MAXPARTS = 2
|
const MAXPARTS = 2
|
||||||
|
|
||||||
var DefaultLoadPath = os.Getenv("HOME") + "/.config/tablizer/lisp"
|
var DefaultLoadPath = os.Getenv("HOME") + "/.config/tablizer/lisp"
|
||||||
@@ -328,7 +328,16 @@ func (conf *Config) PreparePattern(pattern string) error {
|
|||||||
func (conf *Config) ParseConfigfile() error {
|
func (conf *Config) ParseConfigfile() error {
|
||||||
path, err := os.Stat(conf.Configfile)
|
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
|
// ignore non-existent or dirs
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,10 +113,16 @@ func SetupLisp(conf *cfg.Config) error {
|
|||||||
// iterate over load-path and evaluate all *.zy files there, if any
|
// 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
|
// we ignore if load-path does not exist, which is the default anyway
|
||||||
path, err := os.Stat(conf.LispLoadPath)
|
path, err := os.Stat(conf.LispLoadPath)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
// ignore non-existent files
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("failed to stat path: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
// init global hooks
|
// init global hooks
|
||||||
Hooks = make(map[string][]*zygo.SexpSymbol)
|
Hooks = make(map[string][]*zygo.SexpSymbol)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user