mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
10c0bc7383
commit
40470f7d22
|
@ -316,7 +316,9 @@ func (env *ShellEnvironment) Getenv(key string) string {
|
||||||
|
|
||||||
func (env *ShellEnvironment) Pwd() string {
|
func (env *ShellEnvironment) Pwd() string {
|
||||||
defer env.trace(time.Now(), "Pwd")
|
defer env.trace(time.Now(), "Pwd")
|
||||||
|
env.lock.Lock()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
env.lock.Unlock()
|
||||||
env.log(Debug, "Pwd", env.cwd)
|
env.log(Debug, "Pwd", env.cwd)
|
||||||
}()
|
}()
|
||||||
if env.cwd != "" {
|
if env.cwd != "" {
|
||||||
|
@ -728,21 +730,8 @@ func (env *ShellEnvironment) TemplateCache() *TemplateCache {
|
||||||
return tmplCache
|
return tmplCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *ShellEnvironment) DirMatchesOneOf(dir string, regexes []string) (match bool) {
|
func (env *ShellEnvironment) DirMatchesOneOf(dir string, regexes []string) bool {
|
||||||
// sometimes the function panics inside golang, we want to silence that error
|
return dirMatchesOneOf(dir, env.Home(), env.GOOS(), regexes)
|
||||||
// and assume that there's no match. Not perfect, but better than crashing
|
|
||||||
// for the time being until we figure out what the actual root cause is
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
message := fmt.Sprintf("%s", err)
|
|
||||||
env.log(Error, "DirMatchesOneOf", message)
|
|
||||||
match = false
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
env.lock.Lock()
|
|
||||||
defer env.lock.Unlock()
|
|
||||||
match = dirMatchesOneOf(dir, env.Home(), env.GOOS(), regexes)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dirMatchesOneOf(dir, home, goos string, regexes []string) bool {
|
func dirMatchesOneOf(dir, home, goos string, regexes []string) bool {
|
||||||
|
|
Loading…
Reference in a new issue