fix template uninstall : add missing skeleton_tests.hpp and check the symlink target instead of the key phrase

Generated by Mistral Vibe.
This commit is contained in:
hugogogo
2026-10-30 11:45:35 +01:00
parent 403d252fd5
commit bfb9806460
+50 -6
View File
@@ -4,6 +4,7 @@
source ./asides/color.sh source ./asides/color.sh
KEY_PHRASE="#hugogogo#" KEY_PHRASE="#hugogogo#"
HERE=$(pwd)
# receive 1 argument : absolute path to config file # receive 1 argument : absolute path to config file
function restore_bak function restore_bak
@@ -71,15 +72,58 @@ function uninstall
echo # Add a blank line for readability echo # Add a blank line for readability
} }
# receive 1 argument : absolute path to a template file
# same as uninstall(), but for template files (the skeletons) :
# they can't contain the key phrase, it would pollute every generated
# file. so this one checks that the symlink points into this
# repository instead, like install.sh does to find the right file
function uninstall_template
{
local file_to="$1"
local file_name="$(basename "$1")"
local path_file_to="$(dirname "$1")"
echo -e $B_BLUE"--- Uninstalling template \"$file_name\" ---"$ENDCO
# -L check if is symlink
if [ -L "$file_to" ]
then
echo -e $YELLOW"Found symlink: $file_to"$ENDCO
local target_file=$(readlink "$file_to")
if [ "$(realpath -m "$target_file")" = "$HERE/config_files/$file_name" ]
then
echo -e $GREEN"Symlink points to this repository. This is one of our template files."$ENDCO
echo -en $YELLOW"in "
echo -en $CYAN"\"$path_file_to/\""
echo -en $YELLOW", rm symlink "
echo -en $CYAN"\"$file_name\""$ENDCO"\n"
rm "$file_to"
if [ -f "$file_to.hubak0" ]
then
restore_bak "$file_to"
else
echo -e $YELLOW"No backup file found to restore."$ENDCO
fi
else
echo -e $RED"Symlink does not point to this repository. Skipping to avoid removing a file not managed by this script."$ENDCO
fi
else
echo -e $YELLOW"Not a symlink, or does not exist. Skipping: $file_to"$ENDCO
fi
echo # Add a blank line for readability
}
# argument : directory where the config file should go # argument : directory where the config file should go
echo -e $B_MAGENTA"--- Starting uninstall process ---"$ENDCO"\n" echo -e $B_MAGENTA"--- Starting uninstall process ---"$ENDCO"\n"
uninstall "$HOME/.screenrc" uninstall "$HOME/.screenrc"
uninstall "$HOME/.vimrc" uninstall "$HOME/.vimrc"
uninstall "$HOME/.zshrc" uninstall "$HOME/.zshrc"
uninstall "$HOME/.vim/templates/skeleton_colors.h" uninstall_template "$HOME/.vim/templates/skeleton_colors.h"
uninstall "$HOME/.vim/templates/skeleton.cpp" uninstall_template "$HOME/.vim/templates/skeleton_tests.hpp"
uninstall "$HOME/.vim/templates/skeleton.hpp" uninstall_template "$HOME/.vim/templates/skeleton.cpp"
uninstall "$HOME/.vim/templates/skeleton_main.cpp" uninstall_template "$HOME/.vim/templates/skeleton.hpp"
uninstall "$HOME/.vim/templates/skeleton_makefile" uninstall_template "$HOME/.vim/templates/skeleton_main.cpp"
uninstall "$HOME/.vim/templates/skeleton.html" uninstall_template "$HOME/.vim/templates/skeleton_makefile"
uninstall_template "$HOME/.vim/templates/skeleton.html"