11#! /usr/bin/env bash
2- main@bashbox%9836 ()
2+ main@bashbox%7973 ()
33{
4+ function process::self::exit ()
5+ {
6+ kill -USR1 " $___self_PID "
7+ };
48 function log::error ()
59 {
6- local _lasttoken=" $_ " ;
7- local _exception_line=" ${1} " ;
8- local _retcode=" ${2} " ;
9- local IFS='
10- ' ;
10+ local _retcode=" ${2:- $? } " ;
11+ local _exception_line=" $1 " ;
1112 local _source=" ${BB_ERR_SOURCE:- " ${BASH_SOURCE[-1]} " } " ;
12- echo -e " [!!!] \033[1;31merror\033[0m[$_retcode ]: ${_source##*/ } [$BASH_LINENO ]: ${STACK_TRACE :- " $_exception_line " } " 1>&2 ;
13- if test -v STACK_TRACE ; then
13+ echo -e " [!!!] \033[1;31merror\033[0m[$_retcode ]: ${_source} [$BASH_LINENO ]: ${BB_ERR_MSG :- " $_exception_line " } " 1>&2 ;
14+ if test -v BB_ERR_MSG ; then
1415 {
15- echo -e " STACK TRACE: (TOKEN: $_lasttoken ) $ _exception_line" ;
16+ echo -e " STACK TRACE: (TOKEN: $_exception_line ) " 1>&2 ;
1617 local -i _frame=0;
1718 local _treestack=' |--' ;
1819 local _line _caller _source;
1920 while read -r _line _caller _source < <( caller " $_frame " ) ; do
2021 {
21- echo " $_treestack ${_caller} >> ${_source##*/ } ::${_line} " ;
22+ echo " $_treestack ${_caller} >> ${_source##*/ } ::${_line} " 1>&2 ;
2223 _frame+=1;
2324 _treestack+=' --'
2425 };
@@ -27,41 +28,42 @@ main@bashbox%9836 ()
2728 fi ;
2829 return " $_retcode "
2930 };
30- \c ommand \t rap ' exit ' USR1 ;
31- \c ommand \ t rap ' STACK_TRACE="UNCAUGHT EXCEPTION" log::error "$BASH_COMMAND" $? || { kill -USR1 "$___self_PID"; } ' ERR ;
32- \c ommand \u nalias -a ;
31+ \c ommand \u nalias -a || exit ;
32+ trap ' exit ' USR1 ;
33+ trap ' BB_ERR_MSG="UNCAUGHT EXCEPTION" log::error "$BASH_COMMAND" || process::self::exit ' ERR ;
3334 set -eEuT -o pipefail;
3435 shopt -s inherit_errexit expand_aliases;
3536 ___self=" $0 " ;
3637 ___self_PID=" $$ " ;
37- ___MAIN_FUNCNAME=" main@bashbox%9836 " ;
38+ ___MAIN_FUNCNAME=" main@bashbox%7973 " ;
3839 ___self_NAME=" BashBox" ;
3940 ___self_CODENAME=" bashbox" ;
4041 ___self_AUTHORS=(
" AXON <[email protected] >" )
; 41- ___self_VERSION=" 0.2.8 " ;
42+ ___self_VERSION=" 0.2.9 " ;
4243 ___self_DEPENDENCIES=(" std::0.1.5" " argbash::0.1.0" );
4344 ___self_REPOSITORY=" https://github.com/axonasif/bashbox" ;
44- ___self_BASHBOX_COMPAT=" 0.2.8 ~" ;
45+ ___self_BASHBOX_COMPAT=" 0.2.9 ~" ;
4546 function bb_bootstrap_header ()
4647 {
48+ function process::self::exit ()
49+ {
50+ kill -USR1 " $___self_PID "
51+ };
4752 function log::error ()
4853 {
49- local _lasttoken=" $_ " ;
50- local _exception_line=" ${1} " ;
51- local _retcode=" ${2} " ;
52- local IFS='
53- ' ;
54+ local _retcode=" ${2:- $? } " ;
55+ local _exception_line=" $1 " ;
5456 local _source=" ${BB_ERR_SOURCE:- " ${BASH_SOURCE[-1]} " } " ;
55- echo -e " [!!!] \033[1;31merror\033[0m[$_retcode ]: ${_source##*/ } [$BASH_LINENO ]: ${STACK_TRACE :- " $_exception_line " } " 1>&2 ;
56- if test -v STACK_TRACE ; then
57+ echo -e " [!!!] \033[1;31merror\033[0m[$_retcode ]: ${_source} [$BASH_LINENO ]: ${BB_ERR_MSG :- " $_exception_line " } " 1>&2 ;
58+ if test -v BB_ERR_MSG ; then
5759 {
58- echo -e " STACK TRACE: (TOKEN: $_lasttoken ) $ _exception_line" ;
60+ echo -e " STACK TRACE: (TOKEN: $_exception_line ) " 1>&2 ;
5961 local -i _frame=0;
6062 local _treestack=' |--' ;
6163 local _line _caller _source;
6264 while read -r _line _caller _source < <( caller " $_frame " ) ; do
6365 {
64- echo " $_treestack ${_caller} >> ${_source##*/ } ::${_line} " ;
66+ echo " $_treestack ${_caller} >> ${_source##*/ } ::${_line} " 1>&2 ;
6567 _frame+=1;
6668 _treestack+=' --'
6769 };
@@ -70,9 +72,9 @@ main@bashbox%9836 ()
7072 fi ;
7173 return " $_retcode "
7274 };
73- \c ommand \t rap ' exit ' USR1 ;
74- \c ommand \ t rap ' STACK_TRACE="UNCAUGHT EXCEPTION" log::error "$BASH_COMMAND" $? || { kill -USR1 "$___self_PID"; } ' ERR ;
75- \c ommand \u nalias -a ;
75+ \c ommand \u nalias -a || exit ;
76+ trap ' exit ' USR1 ;
77+ trap ' BB_ERR_MSG="UNCAUGHT EXCEPTION" log::error "$BASH_COMMAND" || process::self::exit ' ERR ;
7678 set -eEuT -o pipefail;
7779 shopt -s inherit_errexit expand_aliases
7880 };
530532 _box_dir=" $_repo_source " ;
531533 if test ! -e " $_box_dir " ; then
532534 {
533- log::error " $_box_dir does not exist" 1 || exit
535+ log::error " $_box_dir does not exist" 1 || process::self:: exit
534536 };
535537 fi ;
536538 _arg_force=off;
552554 else
553555 if string::matches " $_repo_source " " [a-zA-Z0-9_]" ; then
554556 {
555- _repo_url=" $( grep " .*/${_repo_source} $" " $_registry_meta_file " ) " || log::error " No such box as $_repo_source was found in the registry" 1 || exit ;
557+ _repo_url=" $( grep " .*/${_repo_source} $" " $_registry_meta_file " ) " || log::error " No such box as $_repo_source was found in the registry" 1 || process::self:: exit;
556558 _box_dir=" $_bashbox_registrydir /${_repo_source} -${_tag_name} " ;
557559 _box_name=" ${_repo_source##*/ } "
558560 };
617619 {
618620 log::info " Compiling $_box in release mode" ;
619621 ( subcommand::build --release " $_box_dir " 2>&1 ) || {
620- log::error " Errors were found while compiling $_box , operation failed" 1 || exit
622+ log::error " Errors were found while compiling $_box , operation failed" 1 || process::self:: exit
621623 };
622624 source " $_box_dir /$_bashbox_meta_name " ;
623625 _built_executable=" $_box_dir /target/release/$CODENAME " ;
@@ -944,7 +946,7 @@ ${YELLOW}${_self_name} ${_subcommand_argv} --release --release -- arg1 arg2 \"st
944946 fi ;
945947 if test ! -e " ${_parsed_input} .sh" && test ! -e " ${_parsed_input} " ; then
946948 {
947- log::error " $_input is missing" 1 || exit
949+ log::error " $_input is missing" 1 || process::self:: exit
948950 };
949951 fi ;
950952 if grep ' \*;$' <<< " $(awk '{$1=$1;print}' <<<" $_input " )" > /dev/null; then
@@ -1550,6 +1552,7 @@ EOF
15501552 done ;
15511553 log::info " Installing to $_target_install_dir " ;
15521554 local _target_full_path=" $_target_install_dir /$___self_CODENAME " ;
1555+ rm -f " $_target_full_path " ;
15531556 echo ' #!/usr/bin/env bash' > " $_target_full_path " ;
15541557 declare -f " ${___MAIN_FUNCNAME} " >> " $_target_full_path " ;
15551558 echo " ${___MAIN_FUNCNAME} \"\$ @\" ;" >> " $_target_full_path " ;
@@ -1558,6 +1561,8 @@ EOF
15581561 };
15591562 function subcommand::clean ()
15601563 {
1564+ read -r bruh < <( false) ;
1565+ read ;
15611566 function print_help ()
15621567 {
15631568 println::helpgen ${_self_name^^} -${_subcommand_argv^^} --short-desc " ${SUBCOMMANDS_DESC[4]} " --usage " ${_self_name} $_subcommand_argv <path>" --examples " ### The basic way:
@@ -1849,4 +1854,4 @@ For bugreports: $___self_REPOSITORY"
18491854 };
18501855 main " $@ "
18511856}
1852- main@bashbox%9836 " $@ " ;
1857+ main@bashbox%7973 " $@ " ;
0 commit comments