detect environment variables desynchronization from .bashrc

This commit is contained in:
pvincent
2025-02-17 11:09:02 +04:00
parent 8e3a116593
commit 10773787ab
2 changed files with 29 additions and 4 deletions
+7 -4
View File
@@ -11,18 +11,20 @@ function bashrc_count_lines {
function bashrc_watch_start {
if [[ -z "${BASHRC_LINES+set}" ]]; then
BASHRC_LINES=$(bashrc_count_lines)
else
BASHRC_EVOLVED=true
fi
}
function bashrc_watch_end {
bashrc_lines=$(bashrc_count_lines)
if [[ "$BASHRC_LINES" -lt "$bashrc_lines" ]]; then
if [[ "$BASHRC_LINES" -lt "$bashrc_lines" || -n "${BASHRC_EVOLVED+set}" ]]; then
echo
echo '*****************************'
echo '* BASHRC has evolved *'
echo '* please execute: *'
echo '* BASHRC has evolved! *'
echo '* please synchronize: *'
echo '* *'
echo "* source \$HOME/.bashrc *"
echo "* source ~/.bashrc *"
echo '* *'
echo '*****************************'
echo
@@ -52,6 +54,7 @@ bashrc_watch_start
echo 'init'
bashrc_env_sync 'SESSION_RESTART' true
bashrc_env_sync 'TOTO' fluo
echo 'end'
bashrc_watch_end