Revamp debugging
This commit is contained in:
parent
b8bd9c2e38
commit
0a1f248269
@ -1,7 +1,7 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
# WARNING: Please make this shell not working-directory dependant, for example
|
# WARNING: Please make this shell not working-directory dependant, for example
|
||||||
# instead of using 'cd blabla', use 'cd "${REPO_DIR}/blabla"'
|
# instead of using 'ls blabla', use 'ls "${REPO_DIR}/blabla"'
|
||||||
#
|
#
|
||||||
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
||||||
#
|
#
|
||||||
|
29
lib-core.sh
29
lib-core.sh
@ -1,16 +1,20 @@
|
|||||||
# WARNING: Please make this shell not working-directory dependant, for example
|
# WARNING: Please make this shell not working-directory dependant, for example
|
||||||
# instead of using 'cd blabla', use 'cd "${REPO_DIR}/blabla"'
|
# instead of using 'ls blabla', use 'ls "${REPO_DIR}/blabla"'
|
||||||
#
|
#
|
||||||
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
|
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
|
||||||
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
|
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
|
||||||
#
|
#
|
||||||
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
||||||
#
|
|
||||||
# WARNING: Please set REPO_DIR variable before using this lib
|
|
||||||
|
|
||||||
set -Eeo pipefail
|
set -Eeo pipefail
|
||||||
WHITESUR_SOURCE=()
|
|
||||||
WHITESUR_SOURCE+=("lib-core.sh")
|
if [[ ! "${REPO_DIR}" ]]; then
|
||||||
|
echo "Please define 'REPODIR' variable"; exit 1
|
||||||
|
elif [[ "${WHITESUR_SOURCE[@]}" =~ "lib-core.sh" ]]; then
|
||||||
|
echo "'lib-core.sh' is already imported"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
WHITESUR_SOURCE=("lib-core.sh")
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# VARIABLES #
|
# VARIABLES #
|
||||||
@ -121,8 +125,7 @@ msg=""
|
|||||||
final_msg="Run '${0} --help' to explore more customization features!"
|
final_msg="Run '${0} --help' to explore more customization features!"
|
||||||
notif_msg=""
|
notif_msg=""
|
||||||
process_ids=()
|
process_ids=()
|
||||||
whitesur_error=""
|
error_snippet=""
|
||||||
whitesur_lines=()
|
|
||||||
export ANIM_PID="0"
|
export ANIM_PID="0"
|
||||||
has_any_error="false"
|
has_any_error="false"
|
||||||
|
|
||||||
@ -485,8 +488,7 @@ rootify() {
|
|||||||
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as root"
|
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as root"
|
||||||
|
|
||||||
if ! sudo "${@}"; then
|
if ! sudo "${@}"; then
|
||||||
whitesur_lines+=("${BASH_LINENO}")
|
error_snippet="${*}"
|
||||||
whitesur_error="${*}"
|
|
||||||
operation_aborted
|
operation_aborted
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -504,8 +506,7 @@ userify() {
|
|||||||
trap true SIGINT
|
trap true SIGINT
|
||||||
|
|
||||||
if ! sudo -u "${MY_USERNAME}" "${@}"; then
|
if ! sudo -u "${MY_USERNAME}" "${@}"; then
|
||||||
whitesur_lines+=("${BASH_LINENO}")
|
error_snippet="${*}"
|
||||||
whitesur_error="${*}"
|
|
||||||
operation_aborted
|
operation_aborted
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -530,8 +531,6 @@ operation_aborted() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#whitesur_lines=($(printf "%s\n" "${whitesur_lines[@]}" | sort -u))
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
prompt -e "\n\n Oops! Operation has been aborted or failed...\n"
|
prompt -e "\n\n Oops! Operation has been aborted or failed...\n"
|
||||||
@ -545,11 +544,11 @@ operation_aborted() {
|
|||||||
prompt -e "FOUND :"
|
prompt -e "FOUND :"
|
||||||
|
|
||||||
for i in "${sources[@]}"; do
|
for i in "${sources[@]}"; do
|
||||||
lines=($(grep -Fn "${whitesur_error:-${BASH_COMMAND}}" "${REPO_DIR}/${i}" | cut -d : -f 1 || echo ""))
|
lines=($(grep -Fn "${error_snippet:-${BASH_COMMAND}}" "${REPO_DIR}/${i}" | cut -d : -f 1 || echo ""))
|
||||||
prompt -e " >>> ${i} $(IFS=';'; [[ "${lines[*]}" ]] && echo "at ${lines[*]}")"
|
prompt -e " >>> ${i} $(IFS=';'; [[ "${lines[*]}" ]] && echo "at ${lines[*]}")"
|
||||||
done
|
done
|
||||||
|
|
||||||
prompt -e "SNIPPET:\n >>> ${whitesur_error:-${BASH_COMMAND}}"
|
prompt -e "SNIPPET:\n >>> ${error_snippet:-${BASH_COMMAND}}"
|
||||||
prompt -e "TRACE :"
|
prompt -e "TRACE :"
|
||||||
|
|
||||||
for i in "${FUNCNAME[@]}"; do
|
for i in "${FUNCNAME[@]}"; do
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
# WARNING: Please make this shell not working-directory dependant, for example
|
# WARNING: Please make this shell not working-directory dependant, for example
|
||||||
# instead of using 'cd blabla', use 'cd "${REPO_DIR}/blabla"'
|
# instead of using 'ls blabla', use 'ls "${REPO_DIR}/blabla"'
|
||||||
#
|
#
|
||||||
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
|
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
|
||||||
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
|
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
|
||||||
#
|
#
|
||||||
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
||||||
#
|
|
||||||
# WARNING: Please set REPO_DIR variable before using this lib
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# VARIABLES #
|
# VARIABLES #
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
# WARNING: Please make this shell not working-directory dependant, for example
|
# WARNING: Please make this shell not working-directory dependant, for example
|
||||||
# instead of using 'cd blabla', use 'cd "${REPO_DIR}/blabla"'
|
# instead of using 'ls blabla', use 'ls "${REPO_DIR}/blabla"'
|
||||||
#
|
#
|
||||||
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user