@@ -294,6 +294,42 @@ load_feature_properties()
294294 fi
295295}
296296
297+
298+ # - Description: Unloads properties loaded from the ${FEATURE_KEYNAME}.dat.sh and functions from the
299+ # ${FEATURE_KEYNAME}.func.sh
300+ # - Permissions: Can be executed indifferently as root or user.
301+ # - Argument 1: Keyname of the properties to unload.
302+ unload_feature_properties ()
303+ {
304+ # Unload functions
305+ unset -f " $1 _install_pre"
306+ unset -f " $1 _install_mid"
307+ unset -f " $1 _install_post"
308+ unset -f " $1 _uninstall_pre"
309+ unset -f " $1 _uninstall_mid"
310+ unset -f " $1 _uninstall_post"
311+
312+ # Unload properties from the .dat.sh
313+ if [ -f " ${CUSTOMIZER_PROJECT_FOLDER} /data/features/$1 /$1 .dat.sh" ]; then
314+ # Select non-commentary lines
315+ while read -r line; do
316+ local variable
317+ variable=" $( echo " ${line} " | grep -v " ^[[:blank:]]*#" | cut -d " =" -f1) "
318+ if [ -z " ${variable} " ]; then
319+ continue
320+ fi
321+ unset " ${variable} "
322+ done < " ${CUSTOMIZER_PROJECT_FOLDER} /data/features/$1 /$1 .dat.sh"
323+ else
324+ output_proxy_executioner " Properties of $1 feature have not been found, so they can not be unloaded. The file
325+ ${CUSTOMIZER_PROJECT_FOLDER} /data/features/$1 /$1 .dat.sh does not exist. " " ERROR"
326+ fi
327+
328+ # Finally unset ${FEATURENAME}_flagsruntime, which is a dynamically declared variable
329+ unset " $1 _flagsruntime"
330+ }
331+
332+
297333# - Description: Performs a post-install clean by using cleaning option of package manager
298334# - Permission: Can be called as root or user.
299335post_install_clean ()
@@ -568,7 +604,8 @@ argument_processing()
568604 exit 0
569605 ;;
570606
571- --readme|readme|features|FEATURES|FEATURES.sh|features.sh) # Print list of possible arguments and finish the program
607+ --readme|readme|features|FEATURES|FEATURES.sh|features.sh)
608+ # Print list of possible arguments and finish the program
572609 autogen_readme
573610 exit 0
574611 ;;
@@ -602,45 +639,57 @@ argument_processing()
602639 add_programs_with_x_permissions 2
603640 ;;
604641
605- * ) # Individual argument
642+ --flush=favorites)
606643 if [ " ${FLAG_MODE} " == " uninstall" ]; then
607- case " ${key} " in
608- --flush=favorites)
609- remove_all_favorites
610- shift
611- continue
612- ;;
613- --flush=keybindings)
614- remove_all_keybindings
615- shift
616- continue
617- ;;
618- --flush=functions)
619- remove_all_functions
620- shift
621- continue
622- ;;
623- --flush=initializations)
624- remove_all_initializations
625- shift
626- continue
627- ;;
628- --flush=structures)
629- remove_structures
630- shift
631- continue
632- ;;
633- --flush=cache)
634- rm -Rf " ${CACHE_FOLDER} "
635- shift
636- continue
637- ;;
638- esac
644+ remove_all_favorites
639645 fi
646+ ;;
640647
641- generate_wrappers # Fill WRAPPERS_KEYNAMES dictionary
648+ --flush=keybindings)
649+ if [ " ${FLAG_MODE} " == " uninstall" ]; then
650+ remove_all_keybindings
651+ fi
652+ ;;
642653
643- local wrapper_key=
654+ --flush=functions)
655+ if [ " ${FLAG_MODE} " == " uninstall" ]; then
656+ remove_all_functions
657+ fi
658+ ;;
659+
660+ --flush=initializations)
661+ if [ " ${FLAG_MODE} " == " uninstall" ]; then
662+ remove_all_initializations
663+ fi
664+ ;;
665+
666+ --flush=structures)
667+ if [ " ${FLAG_MODE} " == " uninstall" ]; then
668+ remove_structures
669+ fi
670+ ;;
671+
672+ --flush=cache)
673+ if [ " ${FLAG_MODE} " == " uninstall" ]; then
674+ rm -Rf " ${CACHE_FOLDER} "
675+ fi
676+ ;;
677+
678+ * )
679+ # Individual argument
680+ # A feature key name was not detected in the current argument ${key}. Try a wrapper.
681+ # But first check that the argument has characters and also check that those characters are valid characters
682+ # for a variable in bash (regexp [a-zA-Z_][a-zA-Z_0-9]*, which is equal to any string using alphanumeric
683+ # characters beginning with ant alphabetic characters and containing underscores at any position)
684+ if [ -z " ${key} " ] || ! echo " ${key} " | grep -Eo " ^[aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ_][aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ_0-9]*$" ; then
685+ output_proxy_executioner " The current argument \" ${key} \" is empty or not valid" " WARNING"
686+ shift
687+ continue
688+ fi
689+
690+ # Indirect expand wrapper variable
691+ generate_wrappers # Fill WRAPPERS_KEYNAMES dictionary
692+ local wrapper_key
644693 wrapper_key=" $( echo " ${key} " | tr " -" " _" ) "
645694 local set_of_features=" ${WRAPPERS_KEYNAMES[${wrapper_key}]} "
646695 if [ -z " ${set_of_features} " ]; then
@@ -658,7 +707,8 @@ argument_processing()
658707
659708 # If we don't receive arguments we try to install everything that we can given our permissions
660709 if [ ${# added_feature_keynames[@]} -eq 0 ]; then
661- output_proxy_executioner " No arguments provided to install feature. Use -h or --help to display information about usage. Aborting..." " WARNING"
710+ output_proxy_executioner " No arguments provided to install feature. Use -h or --help to display information about \
711+ usage. Aborting..." " ERROR"
662712 return
663713 fi
664714}
@@ -932,6 +982,9 @@ execute_installation()
932982 load_feature_properties " ${CURRENT_INSTALLATION_KEYNAME} "
933983
934984 output_proxy_executioner " generic_installation ${keyname} " " COMMAND"
985+
986+ unload_feature_properties " ${CURRENT_INSTALLATION_KEYNAME} "
987+
935988 output_proxy_executioner " ${keyname} ${FLAG_MODE} ed." " INFO"
936989
937990 # Return flag errors to bash defaults (ignore errors)
0 commit comments