From 9e238adbb9db5079cbf4119531709591a626af2e Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Thu, 1 Aug 2024 07:45:34 +0200 Subject: [PATCH] chore(notice): add compiler flag to disable by default resolves #5387 --- src/config/load.go | 2 ++ src/config/notice_default.go | 5 +++++ src/config/notice_disable.go | 15 +++++++++++++++ src/runtime/terminal.go | 1 + 4 files changed, 23 insertions(+) create mode 100644 src/config/notice_default.go create mode 100644 src/config/notice_disable.go diff --git a/src/config/load.go b/src/config/load.go index fd752486..6db74c99 100644 --- a/src/config/load.go +++ b/src/config/load.go @@ -91,5 +91,7 @@ func loadConfig(env runtime.Environment) *Config { return Default(env, true) } + setDisableNotice(data, &cfg) + return &cfg } diff --git a/src/config/notice_default.go b/src/config/notice_default.go new file mode 100644 index 00000000..bbcc47f8 --- /dev/null +++ b/src/config/notice_default.go @@ -0,0 +1,5 @@ +//go:build !disablenotice + +package config + +func setDisableNotice(_ []byte, _ *Config) {} diff --git a/src/config/notice_disable.go b/src/config/notice_disable.go new file mode 100644 index 00000000..0063a588 --- /dev/null +++ b/src/config/notice_disable.go @@ -0,0 +1,15 @@ +//go:build disablenotice + +package config + +import "bytes" + +func setDisableNotice(stream []byte, cfg *Config) { + if !hasKeyInByteStream(stream, "disable_notice") { + cfg.DisableNotice = true + } +} + +func hasKeyInByteStream(data []byte, key string) bool { + return bytes.Contains(data, []byte(key)) +} diff --git a/src/runtime/terminal.go b/src/runtime/terminal.go index 4c0cd8aa..ab28d967 100644 --- a/src/runtime/terminal.go +++ b/src/runtime/terminal.go @@ -75,6 +75,7 @@ func (term *Terminal) Init() { term.sessionCache = initCache(cache.SessionFileName) term.resolveConfigPath() + term.cmdCache = &cache.Command{ Commands: maps.NewConcurrent(), }