diff --git a/.github/workflows/anviltest-base-init-mode.yml b/.github/workflows/anviltest-base-init-mode.yml index 76bd979..cc71eae 100644 --- a/.github/workflows/anviltest-base-init-mode.yml +++ b/.github/workflows/anviltest-base-init-mode.yml @@ -23,4 +23,4 @@ jobs: run: make distcheck - name: Run ./amboso as base init mode, +verbose (-Bi -V 2) - run: ./amboso -Bi -V 2 + run: ./amboso -Bi -V 5 diff --git a/.github/workflows/anviltest-base-purge-mode.yml b/.github/workflows/anviltest-base-purge-mode.yml index e9db0e1..4e0ba94 100644 --- a/.github/workflows/anviltest-base-purge-mode.yml +++ b/.github/workflows/anviltest-base-purge-mode.yml @@ -23,4 +23,4 @@ jobs: run: make distcheck - name: Run ./amboso as base init -> purge mode, +verbose (-Bip -V 2) - run: ./amboso -Bip -V 2 + run: ./amboso -Bip -V 5 diff --git a/.github/workflows/anviltest-git-init-mode.yml b/.github/workflows/anviltest-git-init-mode.yml index ea7b3a0..231b284 100644 --- a/.github/workflows/anviltest-git-init-mode.yml +++ b/.github/workflows/anviltest-git-init-mode.yml @@ -23,4 +23,4 @@ jobs: run: make distcheck - name: Run ./amboso as git init mode, +verbose (-gi -V 2) - run: ./amboso -gi -V 2 + run: ./amboso -gi -V 5 diff --git a/.github/workflows/anviltest-git-purge-mode.yml b/.github/workflows/anviltest-git-purge-mode.yml index df78a3f..ddfae68 100644 --- a/.github/workflows/anviltest-git-purge-mode.yml +++ b/.github/workflows/anviltest-git-purge-mode.yml @@ -23,4 +23,4 @@ jobs: run: make distcheck - name: Run ./amboso as git init -> purge mode, +verbose (-gip -V 2) - run: ./amboso -gip -V 2 + run: ./amboso -gip -V 5 diff --git a/.github/workflows/anviltest-test-macro.yml b/.github/workflows/anviltest-test-macro.yml index 2a268a0..baada8c 100644 --- a/.github/workflows/anviltest-test-macro.yml +++ b/.github/workflows/anviltest-test-macro.yml @@ -26,4 +26,4 @@ jobs: - name: (anviltest) use -t test macro flag, +verbose (-tVV) run: | - ./amboso -tVV || echo -e "\033[1;31mFailed.\e[0m\n" + ./amboso -t -V 5 || echo -e "\033[1;31mFailed.\e[0m\n" diff --git a/.gitignore b/.gitignore index 3331886..d344f0c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ anvil__hello_world.h logic.png #ignore cfg dot output amboso_cfg.dot + +#ignore logfile +anvil.log diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..18b7cd0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,49 @@ +# Changelog + +## [2.0.0] - 2023-12-26 + +### Added +- Add `-P` flag to turn off colored output +- Add `-J` to log output to `anvil.log` +- Add `-R` to turn off `make rebuild` and run `make` +- Add `-F` to force-build a tag +- Run `make` when no arguments are provided + - Closes #87 +- Warn on empty version map +- Warn for detected `mawk` + - Closes #58 +- Warn for `bash 4.x` + - Closes #21 + +### Changed +- Deprecate using `-ti` to record tests + - Closes #91 +- Force `stego.lock` version tags to be strict semver + - Closes #85 +- Run `make rebuild` by default +- Change base mode tags name prefix from `-` to `B` +- Pass `CC` and `CFLAGS` to base mode build + - Closes #5 +- Ignore tests with no `.k` extension + - Closes #84 +- Unify output format to `log_cl` + - Closes #92 +- Colorless amboso sourcing +- Return earlier for `-v` +- Drop `$milestones_dir` +- Drop some comment legacy code +- Generated `.gitignore` for `init` subcommand includes `invil.log`, `anvil.log` +- `verbose_flag` defaults to `3` and allows `[0-5]` + - Closes #90 +- Better error messages when sourcing a deprecated `amboso_fn` + - Closes #82 + - Closes #80 + - Closes #81 + - Closes #83 + - Improved help message + +### Fixed + +- Pass `-C` arguments when doing init + - Closes #89 +- Proper pass of `-V ` to subcalls diff --git a/Makefile b/Makefile index 1e00c87..79ca102 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ export SHELL=/bin/bash -VERSION="1.9.9" -ANVIL_C_HEADER_VERSION="1.9.9" +VERSION="2.0.0" +ANVIL_C_HEADER_VERSION="2.0.0" ECHO_VERSION="./amboso" RUN_VERSION := $(shell $(ECHO_VERSION) -qv) @@ -53,7 +53,8 @@ pack: hello_world install: @echo -en "Installing amboso $(VERSION) globally as 'anvil': " install "./amboso" /usr/local/bin/anvil - @echo -en "Installing amboso_fn.sh $(VERSION) globally as inside '/usr/local/bin':" + @echo -e "\033[1;33mDone.\e[0m" + @echo -en "Installing amboso_fn.sh $(VERSION) globally as inside '/usr/local/bin': " install "./amboso_fn.sh" /usr/local/bin/ @echo -e "\033[1;33mDone.\e[0m" diff --git a/amboso b/amboso index 64f0cdb..c362a7a 100755 --- a/amboso +++ b/amboso @@ -29,9 +29,9 @@ kernel_release="$(uname -r)" kernel_version="$(uname -v)" machine_name="$(uname -m)" os_name="$(uname -o)" -amboso_currvers="1.9.9" -expected_AMBOSO_API_LVL="1.9.9" -amboso_testflag_version="1.9.9" +amboso_currvers="2.0.0" +expected_AMBOSO_API_LVL="2.0.0" +amboso_testflag_version="2.0.0" verbose_flag=0 tell_uname_flag=0 quiet_flag=0 @@ -41,54 +41,54 @@ source_amboso_api() { if [ "$(basename "$(pwd)")" = "amboso" ] ; then { amboso_fn_path="$(realpath "$(pwd)")/amboso_fn.sh" if [ -f "$amboso_fn_path" ] ; then { - [ "$verbose_flag" -gt 1 ] && printf "\033[0;35m[PREP] Running inside amboso dir. Sourcing: \"%s\".\e[0m\n" "$amboso_fn_path">&2 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Running inside amboso dir. Sourcing: \"%s\".\n" "$amboso_fn_path">&2 # shellcheck source=./amboso_fn.sh . "${amboso_fn_path}"; source_res="$?" if [ "$source_res" -ne 0 ] ; then { - printf "\033[1;31m[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 + printf "[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\n" "$amboso_fn_path" >&2 exit 3 } fi } else { - printf "\033[1;31m[ERROR] Couldn't load amboso_fn, check your symlinks.\e[0m\n" + printf "[ERROR] Could not load amboso_fn, check your symlinks.\e[0m\n" exit 2 } fi } else { amboso_fn_path="$(realpath "$(pwd)")/amboso/amboso_fn.sh" found_amboso_dir=0 - [ "$verbose_flag" -gt 1 ] && printf "\033[0;33m[PREP] Assuming we are running in super-repo. Sourcing: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Assuming we are running in super-repo. Sourcing: \"%s\".\n" "$amboso_fn_path" >&2 if [ -d "$(realpath "$(pwd)")"/amboso ]; then { found_amboso_dir=1 } fi - [ "$verbose_flag" -gt 1 ] && [ "$found_amboso_dir" -gt 0 ] && printf "\033[0;32m[PREP] Found amboso dir.\e[0m\n" >&2 + [ "$verbose_flag" -gt 1 ] && [ "$found_amboso_dir" -gt 0 ] && printf "[PREP] Found amboso dir.\n" >&2 if [ -f "$amboso_fn_path" ] ; then { - [ "$verbose_flag" -gt 1 ] && printf "\033[0;35m[PREP] Valid file at: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Valid file at: \"%s\".\n" "$amboso_fn_path" >&2 # shellcheck source=./amboso_fn.sh . "${amboso_fn_path}"; source_res="$?" - [ "$source_res" -ne 0 ] && printf "\033[1;31m[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 + [ "$source_res" -ne 0 ] && printf "[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\n" "$amboso_fn_path" >&2 } else { - [ "$quiet_flag" -eq 0 ] && printf "\033[0;31m[WARN] \"%s\" was not a valid file. Not in valid super-repo.\e[0m\n" "$amboso_fn_path" >&2 + [ "$quiet_flag" -eq 0 ] && printf "[WARN] \"%s\" was not a valid file. Not in valid super-repo.\n" "$amboso_fn_path" >&2 try_default=1 } fi if [ "$try_default" -eq 1 ] && [ -f "/usr/local/bin/amboso_fn.sh" ] ; then { #We only enter here if we failed sourcing #We need one more error message to show me are missing functions because of an amboso directory with no file. if [ "$found_amboso_dir" -gt 0 ] ; then { - printf "\033[1;31m[WARN] Deprecated amboso dir (< 1.4.3) found, as it doesn't provide a function api marker.\e[0m\n\n" >&2 + printf "[WARN] Deprecated amboso dir (< 1.4.3) found, as it doesn't provide a function api marker.\n" >&2 exit 3 } fi amboso_fn_path="/usr/local/bin/amboso_fn.sh" - [ "$quiet_flag" -eq 0 ] && printf "\033[0;35m[WARN] Fallback to default path for amboso_fn. Sourcing: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 + [ "$quiet_flag" -eq 0 ] && printf "[WARN] Fallback to default path for amboso_fn. Sourcing: \"%s\".\n" "$amboso_fn_path" >&2 # shellcheck source=/usr/local/bin/amboso_fn.sh . "$amboso_fn_path"; source_res="$?" if [ "$source_res" -ne 0 ] ; then { - printf "\033[1;31m[PREP] Failed loading amboso_fn. Quitting.\n\n Using file: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 + printf "[PREP] Failed loading amboso_fn. Quitting.\n\n Using file: \"%s\".\n" "$amboso_fn_path" >&2 exit 3 } fi @@ -98,23 +98,35 @@ source_amboso_api() { fi if [ "$source_res" -ne 0 ] ; then { - printf "\033[1;31m[PANIC] Failed sourcing amboso_fn. Expected path: \"%s\".\e[0m\n" "$amboso_fn_path" + printf "[PANIC] Failed sourcing amboso_fn. Expected path: \"%s\".\n" "$amboso_fn_path" exit 2 } fi - [ "$verbose_flag" -gt 1 ] && printf "\033[0;32m[PREP] Done loading functions.\e[0m\n" >&2 - [ "$verbose_flag" -gt 1 ] && printf "\033[0;37m[PREP] \"\$AMBOSO_API_LVL\" is: (\033[0;34m %s \033[0;37m, expected { \033[1;33m%s\033[0;37m } ).\e[0m\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Done loading functions.\n" >&2 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] \"\$AMBOSO_API_LVL\" is: ( %s , expected { %s } ).\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 [ "$tell_uname_flag" -eq 1 ] && print_sysinfo if expr "'$expected_AMBOSO_API_LVL" \> "'$AMBOSO_API_LVL" >/dev/null ; then { - printf "\033[1;31m[PANIC] AMBOSO_API_LVL not supported. Needed { \033[1;35m%s\033[1;31m } , { \033[1;33m%s\033[1;31m } is too low.\n\n Maybe check your \"amboso_fn.sh\" file.\n\e[0m\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" - printf "\033[1;31m[PANIC] Couldn't load functions. Quitting.\e[0m\n" + printf "[PANIC] AMBOSO_API_LVL not supported. Needed { %s } , { %s } is too low.\n\n Maybe check your \"amboso_fn.sh\" file.\n\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" + if [[ "$AMBOSO_API_LVL" < "1.4.3" ]] ; then { + printf "[WARN] amboso_fn.sh does not contain AMBOSO_API_LVL.\n" + } elif [[ "$AMBOSO_API_LVL" > "1.4.2" && "$AMBOSO_API_LVL" < "1.6.6" ]] ; then { + printf "[WARN] Unstable amboso version detected.\n" + } elif [[ "$AMBOSO_API_LVL" > "1.6.5" && "$AMBOSO_API_LVL" < "1.7.4" ]] ; then { + printf "[WARN] Legacy stego.lock format is not supported.\n" + } elif [[ "$AMBOSO_API_LVL" > "1.7.4" && "$AMBOSO_API_LVL" < "1.9.6" ]] ; then { + printf "[WARN] Incompatible -C flag, test mode\n" + } elif [[ "$AMBOSO_API_LVL" < "2.0.0" ]] ; then { + printf "[WARN] Deprecated amboso 1.x API found.\n" + } + fi + printf "[PANIC] Could not load functions. Quitting.\n" exit 2 } elif expr "'$AMBOSO_API_LVL" \> "'$expected_AMBOSO_API_LVL" >/dev/null ; then { - [ "$verbose_flag" -gt 0 ] && printf "\033[0;31m[WARN] AMBOSO_API_LVL is greater than expected. Needed { \033[1;35m%s\033[0;31m } , { \033[1;34m%s\033[0;31m } is higher.\e[0m\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" >&2 - [ "$verbose_flag" -gt 0 ] && printf "\n\033[1;31m[WARN] Continuing run with unexpected AMBOSO_API_LVL: Needed { \033[1;35m%s\033[1;31m } , { \033[1;34m%s\033[1;31m } is higher.\e[0m\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" + [ "$verbose_flag" -gt 0 ] && printf "[WARN] AMBOSO_API_LVL is greater than expected. Needed { %s } , { %s } is higher.\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" >&2 + [ "$verbose_flag" -gt 0 ] && printf "\n[WARN] Continuing run with unexpected AMBOSO_API_LVL: Needed { %s } , { %s } is higher.\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" #exit 2 } elif [ "$AMBOSO_API_LVL" = "$expected_AMBOSO_API_LVL" ] ; then { - [ "$verbose_flag" -gt 0 ] && printf "\033[0;32m[PREP] Running with \"\$AMBOSO_API_LVL\" [ \033[1;35m%s\033[0;32m ]; min is { \033[1;36m%s\033[0;32m }.\e[0m\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 + [ "$verbose_flag" -gt 0 ] && printf "[PREP] Running with \"\$AMBOSO_API_LVL\" [ %s ]; min is { %s }.\e[0m\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 } fi } diff --git a/amboso_fn.sh b/amboso_fn.sh index 1738b7a..a8cefea 100644 --- a/amboso_fn.sh +++ b/amboso_fn.sh @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AMBOSO_API_LVL="1.9.9" +AMBOSO_API_LVL="2.0.0" at () { printf "{ call: [$(( ${#BASH_LINENO[@]} - 1 ))] " for ((i=${#BASH_LINENO[@]}-1;i>=0;i--)); do @@ -51,8 +51,204 @@ trace () { fi } +function log_cl { + has_color="${AMBOSO_COLOR:-0}" + do_filelog="${AMBOSO_LOGGED:-0}" + tk_bold="bold" + tk_thin="thin" + clr_default="0" + clr_red="1" + clr_green="2" + clr_yellow="3" + clr_blue="4" + clr_magenta="5" + clr_cyan="6" + clr_white="7" + colorname_0="default" + colorname_1="red" + colorname_2="green" + colorname_3="yellow" + colorname_4="blue" + colorname_5="magenta" + colorname_6="cyan" + colorname_7="white" + + lvl_4="debug" + lvl_3="info" + lvl_2="warn" + lvl_1="error" + + lvl_4_tag="DEBUG" + lvl_3_tag="INFO" + lvl_2_tag="WARN" + lvl_1_tag="ERROR" + + msg="$1" + lvl="$2" + color="$3" + thick="$4" + [[ -z "$thick" ]] && thick="thin" + + verb_lvl=3 + lvl_tag="" + begin_color=0 + thickness=0 + + case $lvl in + "") + : + ;; + "$lvl_4") + verb_lvl=4 + lvl_tag="$lvl_4_tag" + begin_color="$clr_magenta" + ;; + "$lvl_3") + verb_lvl=3 + lvl_tag="$lvl_3_tag" + begin_color="$clr_green" + ;; + "$lvl_2") + verb_lvl=2 + lvl_tag="$lvl_2_tag" + begin_color="$clr_yellow" + ;; + "$lvl_1") + verb_lvl=1 + lvl_tag="$lvl_1_tag" + begin_color="$clr_red" + ;; + *) + printf "${FUNCNAME[0]}(): unexpected lvl => {$lvl}\n" + exit 1 + ;; + esac + case $thick in + "") + : + ;; + "$tk_bold") + thickness=1 + ;; + "$tk_thin") + : + ;; + *) + printf "${FUNCNAME[0]}(): unexpected thickness => {$thick}\n" + exit 1 + ;; + esac + case $color in + "") + : + ;; + "$colorname_0") + begin_color="$clr_default" + ;; + "$colorname_1") + begin_color="$clr_red" + ;; + "$colorname_2") + begin_color="$clr_green" + ;; + "$colorname_3") + begin_color="$clr_yellow" + ;; + "$colorname_4") + begin_color="$clr_blue" + ;; + "$colorname_5") + begin_color="$clr_magenta" + ;; + "$colorname_6") + begin_color="$clr_cyan" + ;; + "$colorname_7") + begin_color="$clr_white" + ;; + *) + printf "${FUNCNAME[0]}(): unexpected color => {$color}\n" + exit 1 + ;; + esac + + if [[ "$msg" =~ ^\[ ]] ; then { + lvl_tag="" + } + fi + + if [[ "$has_color" -le 0 ]] ; then { + begin_color=0 + } + fi + + #printf "thick: {$thickness}\nclr: {$begin_color}\nlvl_tag: {$lvl_tag}\nmsg: {$msg}\n\n" + if [[ "$begin_color" -eq 0 && -z "$lvl_tag" ]] ; then { + printf "$msg\n" + [[ "$do_filelog" -gt 0 ]] && printf "$msg\n" >> "./anvil.log" + } elif [[ "$begin_color" -eq 0 && ! -z "$lvl_tag" ]] ; then { + printf "[$lvl_tag] $msg\n" + [[ "$do_filelog" -gt 0 ]] && printf "[$lvl_tag] $msg\n" >> "./anvil.log" + } elif [[ -z "$lvl_tag" ]] ; then { + printf "\033[$thickness;3${begin_color}m$msg\033[0m\n" + [[ "$do_filelog" -gt 0 ]] && printf "$msg\n" >> "./anvil.log" + } else { + printf "\033[$thickness;3${begin_color}m[$lvl_tag] $msg\033[0m\n" + [[ "$do_filelog" -gt 0 ]] && printf "[$lvl_tag] $msg\n" >> "./anvil.log" + } + fi +} + +function echo_amboso_splash { + amboso_version="$1" + prog="$2" + printf "amboso, v$amboso_version\nCopyright (C) 2023 jgabaut\n\n This program comes with ABSOLUTELY NO WARRANTY; for details type \`$prog -W\`.\n This is free software, and you are welcome to redistribute it\n under certain conditions; see file \`LICENSE\` for details.\n\n Full source is available at https://github.com/jgabaut/amboso\n\n" +} + +function echo_invil_notice { + log_cl "The bash implementation of amboso is being ported to Rust." info + log_cl "amboso v2.x is going to try to maintain compatibility with \"invil\", the new reference implementation, but it may fail to do so proptly." warn + log_cl "You can find the new version at https://github.com/jgabaut/invil" info +} + +function try_doing_make { + if [[ -f "./Makefile" ]] ; then { + log_cl "Found Makefile." info + make + make_res="$?" + if [[ "$make_res" -ne 0 ]] ; then { + log_cl "\"make\" failed." info + return "$make_res" + } + fi + return "$make_res" + } elif [[ -f "./configure.ac" && -f "./Makefile.am" ]] ; then { + log_cl "Found:\n\n configure.ac\n\n Makefile.am" info + autoreconf + automake --add-missing + autoreconf + ./configure + make + make_res="$?" + if [[ "$make_res" -ne 0 ]] ; then { + log_cl "\"automake\" failed." info + return "$make_res" + } + fi + return "$make_res" + } else { + log_cl "Can't find a Makefile or a configure.ac, quitting." warn + return 1 + } + fi +} + function echo_active_flags { + printf "[ENV] Args:\n\n" + printf " CC \"%s\"\n" "$CC" + printf " CFLAGS \"%s\"\n\n" "$CFLAGS" printf "[DEBUG] Current flags:\n\n" + printf " [MODE] -" [[ $small_test_mode_flag -gt 0 ]] && printf "t" [[ $test_mode_flag -gt 0 ]] && printf "T" @@ -67,11 +263,15 @@ function echo_active_flags { done } fi + [[ $force_build_flag -gt 0 ]] && printf "F" + [[ $enable_make_rebuild_flag -ne 1 ]] && printf "R" + [[ $do_filelog_flag -gt 0 ]] && printf "J" + [[ $allow_color_flag -lt 1 ]] && printf "P" [[ $gen_C_headers_flag -gt 0 ]] && printf "G" [[ $be_stego_parser_flag -gt 0 ]] && printf "x" [[ $show_time_flag -gt 0 ]] && printf "w" [[ $start_time_flag -gt 0 ]] && printf "C" - [[ $ignore_git_check_flag -gt 0 ]] && printf"X" + [[ $ignore_git_check_flag -gt 0 ]] && printf "X" [[ $show_warranty_flag -gt 0 ]] && printf "W" [[ $tell_uname_flag -gt 0 ]] && printf "U" [[ $pack_flag -gt 0 ]] && printf "z" @@ -107,7 +307,7 @@ function echo_amboso_version_short { function echo_timer { if [[ $show_time_flag -eq 0 ]] ; then { - [[ $verbose_flag -eq 0 || $quiet_flag -gt 0 ]] && return + [[ $verbose_flag -le 3 || $quiet_flag -gt 0 ]] && return } fi st="$1" @@ -122,7 +322,7 @@ function echo_timer { display_zero="" } fi - printf "\033[1;36m[TIME]\e[0m [ \033[1;3${color}m\"$msg\"\e[0m ] Took [ \033[1;33m$display_zero$runtime\e[0m ] seconds.\n" + log_cl "[TIME] [ \"$msg\" ] Took [ $display_zero$runtime ] seconds." info return } @@ -133,40 +333,18 @@ function check_tags { # For bash 3.x+, must not be in posix mode, may use temporary files while IFS='' read -r line; do repo_tags+=("$line"); done < <(git tag -l) - # LEGACY - # - #if [[ $verbose_flag -gt 1 ]] ; then { - # for tag in "${read_versions[@]}"; do - # if [[ " ${repo_tags[*]} " =~ " $tag " ]]; then - # if [[ $verbose_flag -gt 0 ]] ; then { - # shown_tag="\033[1;32m$tag\e[0m" - # printf "[AMBOSO] Read Tag $shown_tag exists in the repo.\n" >&2 - # } - # fi - # else { - # if [[ $verbose_flag -gt 0 ]] ; then { - # shown_tag="\033[1;31m$tag\e[0m" - # printf "[AMBOSO] Read Tag $shown_tag is missing in the repo.\n" >&2 - # } - # fi - # } - # fi - # done - #} - #fi - for tag in "${supported_versions[@]}"; do if [[ " ${repo_tags[*]} " =~ " $tag " ]]; then { latest_version="$tag" - if [[ $verbose_flag -gt 0 ]] ; then { - shown_tag="\033[1;32m$tag\e[0m" - printf "[AMBOSO] Supported Tag $shown_tag exists in the repo.\n" >&2 + if [[ $verbose_flag -gt 3 ]] ; then { + shown_tag="$tag" + log_cl "[AMBOSO] Supported Tag $shown_tag exists in the repo." warn >&2 } fi } else { - if [[ $verbose_flag -gt 0 ]] ; then { - shown_tag="\033[1;31m$tag\e[0m" - printf "[AMBOSO] Supported Tag $shown_tag is missing in the repo.\n" >&2 + if [[ $verbose_flag -gt 3 ]] ; then { + shown_tag="$tag" + log_cl "[AMBOSO] Supported Tag $shown_tag is missing in the repo." warn >&2 } fi } @@ -179,45 +357,45 @@ function echo_tag_info { tag_date=$(git show -q --clear-decorations "$tag" 2>/dev/null | grep Date | cut -f2 -d':') tag_author=$(git show -q --clear-decorations "$tag" 2>/dev/null | grep Author | cut -f2 -d':' | cut -f2 -d' ') tag_txt=$(git show -q --clear-decorations "$tag" 2>/dev/null | tail -n2 | grep -v '^$') - printf "\033[1;33m[AMBOSO] Tag text was: \033[1;34m[$tag_txt ]\e[0m\n" - printf "\033[1;33m[AMBOSO] Tag author was: \033[1;34m[$tag_author ]\e[0m\n" - printf "\033[1;33m[AMBOSO] Tag date was: \033[1;34m[$tag_date ]\e[0m\n" + log_cl "[AMBOSO] Tag text was: [$tag_txt]" info + log_cl "[AMBOSO] Tag author was: [$tag_author ]" info + log_cl "[AMBOSO] Tag date was: [$tag_date ]" info } function amboso_init_proj { target_dir="$1" if [[ ! -d "$target_dir" ]] ; then { - printf "\033[1;31m[ERROR]\033[0m Invalid dir: {$target_dir}.\n" + log_cl "Invalid dir: {$target_dir}." error if [[ ! -e "$target_dir" ]] ; then { - printf "\033[1;33m[WARN]\033[0m Trying to mkdir: {$target_dir}.\n" + log_cl "Trying to mkdir: {$target_dir}." warn mkdir "$target_dir" mkdir_res="$?" if [[ "$mkdir_res" -eq 0 ]] ; then { - printf "\033[1;32m[INFO]\033[0m Created dir: {$target_dir}.\n" + log_cl "Created dir: {$target_dir}." info } else { - printf "\033[1;31m[ERROR]\033[0m Failed mkdir for: {$target_dir}.\n" + log_cl "Failed mkdir for: {$target_dir}." error return 1 } fi } else { - printf "\033[1;31m[ERROR]\033[0m {$target_dir} already exists and it is not a directory.\n" + log_cl "{$target_dir} already exists and it is not a directory." error return 1 } fi } fi is_git_repo=0 - ( cd "$target_dir" || { printf "\033[1;31m[CRITICAL]\033[0m cd failed for {$target_dir}.\n"; return 1 ; } ; + ( cd "$target_dir" || { log_cl "[CRITICAL] cd failed for {$target_dir}." error ; return 1 ; } ; #Check if target dir is a repo git rev-parse --is-inside-work-tree 2>/dev/null 1>&2 ) is_git_repo="$?" if [[ $is_git_repo -eq 0 ]] ; then { - printf "\n\033[1;31m[ERROR] {$target_dir} is a git repo. Quitting..\e[0m\n\n" + log_cl "{$target_dir} is a git repo. Quitting.." error return 1 } fi - printf "\033[1;35m[PREP]\033[0m New amboso project in {\033[1;33m$target_dir\033[0m}\n" + log_cl "[PREP] New amboso project in {$target_dir}" info mkdir -p "$target_dir"/src mkdir -p "$target_dir"/bin @@ -230,24 +408,26 @@ function amboso_init_proj { printf "#include \nint main(void) {\nprintf(\"Hello, World!\");\nreturn 0;\n}\n" > "$target_dir"/src/main.c - printf "# ignore object files\n*.o\n# also explicitly ignore our executable for good measure\nhello_world\n# also explicitly ignore our windows executable for good measure\nhello_world.exe\n# also explicitly ignore our debug executable for good measure\nhello_world_debug\n#We also want to ignore the dotfile dump if we ever use anvil with -c flag\namboso_cfg.dot\n# MacOS DS_Store ignoring\n.DS_Store\n# ignore debug log file\ndebug_log.txt\n# ignore files generated by Autotools\nautom4te.cache/\ncompile\nconfig.guess\nconfig.log\nconfig.status\nconfig.sub\nconfigure\ninstall-sh\nmissing\naclocal.m4\nconfigure~\nMakefile\nMakefile.in\n" > "$target_dir"/.gitignore + printf "#Generated by amboso v$amboso_currvers\n# ignore object files\n*.o\n# also explicitly ignore our executable for good measure\nhello_world\n# also explicitly ignore our windows executable for good measure\nhello_world.exe\n# also explicitly ignore our debug executable for good measure\nhello_world_debug\n#We also want to ignore the dotfile dump if we ever use anvil with -c flag\namboso_cfg.dot\n# MacOS DS_Store ignoring\n.DS_Store\n# ignore debug log file\ndebug_log.txt\n# ignore files generated by Autotools\nautom4te.cache/\ncompile\nconfig.guess\nconfig.log\nconfig.status\nconfig.sub\nconfigure\ninstall-sh\nmissing\naclocal.m4\nconfigure~\nMakefile\nMakefile.in\n# ignore amboso log file\nanvil.log\n#ignore invil log file\ninvil.log\n" > "$target_dir"/.gitignore - printf "AC_INIT([hello_world], [0.1.0], [email@example.com])\nAM_INIT_AUTOMAKE([foreign -Wall])\nAC_CANONICAL_HOST\necho \"Host os: \$host_os\"\nAM_CONDITIONAL([OS_DARWIN], [test \"\$host_os\" = \"darwin\"])\nAM_CONDITIONAL([MINGW32_BUILD], [test \"\$host_os\" = \"mingw32\"])\nAC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable debug build])], [enable_debug=\$enableval], [enable_debug=no])\nAM_CONDITIONAL([DEBUG_BUILD], [test \"\$enable_debug\" = \"yes\"])\nif test \"\$host_os\" = \"mingw32\"; then\n echo \"Building for mingw32: [\$host_cpu-\$host_vendor-\$host_os]\"\n AC_SUBST([HW_CFLAGS], [\"-I/usr/x86_64-w64-mingw32/include -static -fstack-protector -DMINGW32_BUILD\"])\n AC_SUBST([HW_LDFLAGS], [\"-L/usr/x86_64-w64-mingw32/lib\"])\n AC_SUBST([CCOMP], [\"/usr/bin/x86_64-w64-mingw32-gcc\"])\n AC_SUBST([OS], [\"w64-mingw32\"])\n AC_SUBST([TARGET], [\"hello_world.exe\"])\nfi\nif test \"\$host_os\" = \"darwin\"; then\n echo \"Building for macos: [\$host_cpu-\$host_vendor-\$host_os]\"\n AC_SUBST([HW_CFLAGS], [\"-I/opt/homebrew/opt/ncurses/include\"])\n AC_SUBST([HW_LDFLAGS], [\"-L/opt/homebrew/opt/ncurses/lib\"])\n AC_SUBST([OS], [\"darwin\"])\n AC_SUBST([TARGET], [\"hello_world\"])\nfi\nif test \"\$host_os\" = \"linux-gnu\"; then\n echo \"Building for Linux: [\$host_cpu-\$host_vendor-\$host_os]\"\n AC_SUBST([HW_CFLAGS], [\"\"])\n AC_SUBST([HW_LDFLAGS], [\"\"])\n AC_SUBST([OS], [\"Linux\"])\n AC_SUBST([TARGET], [\"hello_world\"])\nfi\nAC_ARG_VAR([VERSION], [Version number])\nif test -z \"\$VERSION\"; then\n VERSION=\"0.3.11\"\nfi\nAC_DEFINE_UNQUOTED([VERSION], [\"\$VERSION\"], [Version number])\nAC_CHECK_PROGS([CCOMP], [gcc clang])\nAC_CHECK_HEADERS([stdio.h])\nAC_CHECK_FUNCS([malloc calloc])\nAC_CONFIG_FILES([Makefile])\nAC_OUTPUT\n" > "$target_dir"/configure.ac + printf "#Generated by amboso v$amboso_currvers\nAC_INIT([hello_world], [0.1.0], [email@example.com])\nAM_INIT_AUTOMAKE([foreign -Wall])\nAC_CANONICAL_HOST\necho \"Host os: \$host_os\"\nAM_CONDITIONAL([OS_DARWIN], [test \"\$host_os\" = \"darwin\"])\nAM_CONDITIONAL([MINGW32_BUILD], [test \"\$host_os\" = \"mingw32\"])\nAC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable debug build])], [enable_debug=\$enableval], [enable_debug=no])\nAM_CONDITIONAL([DEBUG_BUILD], [test \"\$enable_debug\" = \"yes\"])\nif test \"\$host_os\" = \"mingw32\"; then\n echo \"Building for mingw32: [\$host_cpu-\$host_vendor-\$host_os]\"\n AC_SUBST([HW_CFLAGS], [\"-I/usr/x86_64-w64-mingw32/include -static -fstack-protector -DMINGW32_BUILD\"])\n AC_SUBST([HW_LDFLAGS], [\"-L/usr/x86_64-w64-mingw32/lib\"])\n AC_SUBST([CCOMP], [\"/usr/bin/x86_64-w64-mingw32-gcc\"])\n AC_SUBST([OS], [\"w64-mingw32\"])\n AC_SUBST([TARGET], [\"hello_world.exe\"])\nfi\nif test \"\$host_os\" = \"darwin\"; then\n echo \"Building for macos: [\$host_cpu-\$host_vendor-\$host_os]\"\n AC_SUBST([HW_CFLAGS], [\"-I/opt/homebrew/opt/ncurses/include\"])\n AC_SUBST([HW_LDFLAGS], [\"-L/opt/homebrew/opt/ncurses/lib\"])\n AC_SUBST([OS], [\"darwin\"])\n AC_SUBST([TARGET], [\"hello_world\"])\nfi\nif test \"\$host_os\" = \"linux-gnu\"; then\n echo \"Building for Linux: [\$host_cpu-\$host_vendor-\$host_os]\"\n AC_SUBST([HW_CFLAGS], [\"\"])\n AC_SUBST([HW_LDFLAGS], [\"\"])\n AC_SUBST([OS], [\"Linux\"])\n AC_SUBST([TARGET], [\"hello_world\"])\nfi\nAC_ARG_VAR([VERSION], [Version number])\nif test -z \"\$VERSION\"; then\n VERSION=\"0.3.11\"\nfi\nAC_DEFINE_UNQUOTED([VERSION], [\"\$VERSION\"], [Version number])\nAC_CHECK_PROGS([CCOMP], [gcc clang])\nAC_CHECK_HEADERS([stdio.h])\nAC_CHECK_FUNCS([malloc calloc])\nAC_CONFIG_FILES([Makefile])\nAC_OUTPUT\n" > "$target_dir"/configure.ac - printf "AUTOMAKE_OPTIONS = foreign\nCFLAGS = @CFLAGS@\nSHELL := /bin/bash\n.ONESHELL:\nMACHINE := \$\$(uname -m)\nPACK_NAME = \$(TARGET)-\$(VERSION)-\$(OS)-\$(MACHINE)\nhello_world_SOURCES = src/main.c\nLDADD = \$(HW_LDFLAGS)\nAM_LDFLAGS = -O2\nAM_CFLAGS = \$(HW_CFLAGS) -O2 -Werror -Wpedantic -Wall\nif DEBUG_BUILD\nAM_LDFLAGS += -ggdb -O0\nAM_CFLAGS += \"\"\nelse\nAM_LDFLAGS += -s\nendif\n%%.o: %%.c\n \$(CCOMP) -c \$(CFLAGS) \$(AM_CFLAGS) $< -o \$@\n\$(TARGET): \$(hello_world_SOURCES:.c=.o)\n @echo -e \" AM_CFLAGS: [ \$(AM_CFLAGS) ]\"\n @echo -e \" LDADD: [ \$(LDADD) ]\"\n \$(CCOMP) \$(CFLAGS) \$(AM_CFLAGS) \$(hello_world_SOURCES:.c=.o) -o \$@ \$(LDADD) \$(AM_LDFLAGS)\nclean:\n @echo -en \"Cleaning build artifacts: \"\n -rm \$(TARGET)\n -rm src/*.o\n -rm static/*.o\n @echo -e \"Done.\"\ncleanob:\n @echo -en \"Cleaning object build artifacts: \"\n -rm src/*.o\n -rm static/*.o\n @echo -e \"Done.\"\nanviltest:\n @echo -en \\\"Running anvil tests.\"\n ./anvil -tX\n @echo -e \"Done.\"\nall: \$(TARGET)\nrebuild: clean all\n.DEFAULT_GOAL := all\n" > "$target_dir"/Makefile.am + printf "#Generated by amboso v$amboso_currvers\nAUTOMAKE_OPTIONS = foreign\nCFLAGS = @CFLAGS@\nSHELL := /bin/bash\n.ONESHELL:\nMACHINE := \$\$(uname -m)\nPACK_NAME = \$(TARGET)-\$(VERSION)-\$(OS)-\$(MACHINE)\nhello_world_SOURCES = src/main.c\nLDADD = \$(HW_LDFLAGS)\nAM_LDFLAGS = -O2\nAM_CFLAGS = \$(HW_CFLAGS) -O2 -Werror -Wpedantic -Wall\nif DEBUG_BUILD\nAM_LDFLAGS += -ggdb -O0\nAM_CFLAGS += \"\"\nelse\nAM_LDFLAGS += -s\nendif\n\n%%.o: %%.c\n\t\$(CCOMP) -c \$(CFLAGS) \$(AM_CFLAGS) $< -o \$@\n\n\$(TARGET): \$(hello_world_SOURCES:.c=.o)\n\t@echo -e \" CFLAGS: [ \$(CFLAGS) ]\"\n\t@echo -e \" AM_CFLAGS: [ \$(AM_CFLAGS) ]\"\n\t@echo -e \" LDADD: [ \$(LDADD) ]\"\n\t\$(CCOMP) \$(CFLAGS) \$(AM_CFLAGS) \$(hello_world_SOURCES:.c=.o) -o \$@ \$(LDADD) \$(AM_LDFLAGS)\n\nclean:\n\t@echo -en \"Cleaning build artifacts: \"\n\t-rm \$(TARGET)\n\t-rm src/*.o\n\t-rm static/*.o\n\t@echo -e \"Done.\"\n\ncleanob:\n\t@echo -en \"Cleaning object build artifacts: \"\n\t-rm src/*.o\n\t-rm static/*.o\n\t@echo -e \"Done.\"\n\nanviltest:\n\t@echo -en \\\"Running anvil tests.\"\n\t./anvil -tX\n\t@echo -e \"Done.\"\n\nall: \$(TARGET)\nrebuild: clean all\n.DEFAULT_GOAL := all\n" > "$target_dir"/Makefile.am - printf "\033[1;34m[INFO]\033[0m Creating new repo in {\033[1;35m$target_dir\033[0m}\n" + log_cl "Creating new repo in {$target_dir}" info - ( cd "$target_dir" || { printf "\033[1;31m[CRITICAL]\033[0m cd failed for {$target_dir}.\n"; return 1 ; } ; + ( cd "$target_dir" || { log_cl "[CRITICAL] cd failed for {$target_dir}." error ; return 1 ; } ; git init - [[ $quiet_flag -eq 0 ]] && printf "\033[1;32m[INFO]\033[0m Initialised git repo\n" + [[ $quiet_flag -eq 0 ]] && log_cl "Initialised git repo" info git submodule add --depth 1 "git@github.com:jgabaut/amboso.git" - [[ $quiet_flag -eq 0 ]] && printf "\033[1;32m[INFO]\033[0m Added amboso submodule\n" + [[ $quiet_flag -eq 0 ]] && log_cl "Added amboso submodule" info ln -s "amboso/amboso" "anvil" - [[ $quiet_flag -eq 0 ]] && printf "\033[1;32m[INFO]\033[0m Symlinked \"\033[1;34mamboso/amboso\033[0m\" to \"\033[1;35m./anvil\033[0m\"\n" + res="$?" + [[ $quiet_flag -eq 0 ]] && log_cl "Symlinked \"mamboso/amboso\" to \"./anvil\"" info + exit "$res" ) - [[ $? -eq 0 ]] || { printf "\033[1;31m[ERROR]\033[0m git prep failed for {$target_dir}.\n"; return 1 ; } ; - [[ $quiet_flag -eq 0 ]] && printf "\033[1;35m[INFO]\033[0m Done init for {\033[1;36m$target_dir\033[0m\n" + [[ "$?" -eq 0 ]] || { log_cl "git prep failed for {$target_dir}." error ; return 1 ; } ; + [[ $quiet_flag -eq 0 ]] && log_cl "Done init for {$target_dir}" info } function gen_C_headers { @@ -259,10 +439,10 @@ function gen_C_headers { tag_date=$(git show -q --clear-decorations "$tag" 2>/dev/null | grep Date | cut -f2 -d':') tag_author=$(git show -q --clear-decorations "$tag" 2>/dev/null | grep Author | cut -f2 -d':' | cut -f2 -d' ') tag_txt=$(git show -q --clear-decorations "$tag" 2>/dev/null | head -n1 | grep -v '^$') - printf "\033[1;35m[AMBOSO] Gen C header for ($execname), v($tag) to dir ($target_dir)\e[0m\n" - printf "\033[1;35m[AMBOSO] Reset file ($target_dir/$headername)\n" + log_cl "[AMBOSO] Gen C header for ($execname), v($tag) to dir ($target_dir)" info + log_cl "[AMBOSO] Reset file ($target_dir/$headername)" info printf "" > "$target_dir/$headername" - printf "\033[1;35m[AMBOSO] Reset file ($target_dir/$c_headername)\n" + log_cl "[AMBOSO] Reset file ($target_dir/$c_headername)" info printf "" > "$target_dir/$c_headername" printf "//Generated by amboso v$AMBOSO_API_LVL\n" >> "$target_dir/$headername" printf "//Repo at https://github.com/jgabaut/amboso\n\n" >> "$target_dir/$headername" @@ -300,29 +480,36 @@ function set_supported_tests { #tests loop cases_path="$kazoj_dir/$cases_dir" if [[ ! -d $cases_path ]]; then { - printf "\033[0;33m[DEBUG]\e[0m \"$cases_path\" was not a valid directory.\n\n" + log_cl "\"$cases_path\" was not a valid directory.\n" debug return 1 } fi errorcases_path="$kazoj_dir/$errors_dir" if [[ ! -d $errorcases_path ]]; then { - printf "\033[0;33m[DEBUG]\e[0m \"$errorcases_path\" was not a valid directory.\n\n" + log_cl "\"$errorcases_path\" was not a valid directory.\n" debug return 1 } fi for FILE in "$cases_path"/* ; do { - [[ -e "$FILE" ]] || { printf "$FILE did not exist\n" ; continue ;} + [[ -e "$FILE" ]] || { log_cl "{$FILE} did not exist." warn ; continue ;} test_fp="$cases_path/$(basename "$FILE")" - extens=$(printf "$(realpath "$(basename "$FILE")")\n" | cut -d '.' -f '2') - if [[ $extens = "stderr" || $extens = "stdout" ]] ; then { + extens=$(printf "$(realpath "$(basename "$FILE")")\n" | awk -F"." '{print $2}') + if [[ "$extens" != "k" ]] ; then { + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "{$test_fp} does not have .k extension." warn + skipped=$((skipped+1)) + continue + } + fi + double_extens=$(printf "$(realpath "$(basename "$FILE")")\n" | awk -F"." '{print $3}') + if [[ "$double_extens" = "stderr" || "$double_extens" = "stdout" ]] ; then { skipped=$((skipped+1)) - [[ $verbose_flag -gt 1 && $quiet_flag -eq 0 ]] && printf "\033[0;37m[PREP-TEST] Skip record $FILE (at $(dirname "$test_fp")).\e[0m\n" >&2 + [[ $verbose_flag -ge 4 && $quiet_flag -eq 0 ]] && log_cl "[PREP-TEST] Skip record $FILE (at $(dirname "$test_fp"))." debug >&2 continue } fi if ! [[ -f $test_fp && -x $test_fp ]] ; then { skipped=$((skipped+1)) - [[ $verbose_flag -gt 1 && $quiet_flag -eq 0 ]] && printf "\033[0;36m[PREP-TEST] Skip test \"$FILE\" (at $(dirname "$test_fp")), not an executable.\e[0m\n" >&2 + [[ $verbose_flag -ge 4 && $quiet_flag -eq 0 ]] && log_cl "[PREP-TEST] Skip test \"$FILE\" (at $(dirname "$test_fp")), not an executable." debug >&2 continue } fi @@ -332,18 +519,25 @@ function set_supported_tests { done #errors loop for FILE in "$errorcases_path"/* ; do { - [[ -e "$FILE" ]] || { printf "$FILE did not exist\n" ; continue ;} + [[ -e "$FILE" ]] || { log_cl "{$FILE} did not exist." warn ; continue ;} test_fp="$errorcases_path/$(basename "$FILE")" - extens=$(printf "$(realpath "$(basename "$FILE")")\n" | cut -d '.' -f '2') - if [[ $extens = "stderr" || $extens = "stdout" ]] ; then { + extens=$(printf "$(realpath "$(basename "$FILE")")\n" | awk -F"." '{print $2}') + if [[ "$extens" != "k" ]] ; then { + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "{$test_fp} does not have .k extension." warn skipped=$((skipped+1)) - [[ $verbose_flag -gt 1 && $quiet_flag -eq 0 ]] && printf "\033[0;37m[PREP-TEST] Skip record $FILE (at $(dirname "$test_fp")).\e[0m\n" >&2 + continue + } + fi + double_extens=$(printf "$(realpath "$(basename "$FILE")")\n" | awk -F"." '{print $3}') + if [[ "$double_extens" = "stderr" || "$double_extens" = "stdout" ]] ; then { + skipped=$((skipped+1)) + [[ $verbose_flag -ge 4 && $quiet_flag -eq 0 ]] && log_cl "[PREP-TEST] Skip record $FILE (at $(dirname "$test_fp"))." debug >&2 continue } fi if ! [[ -f $test_fp && -x $test_fp ]] ; then { skipped=$((skipped+1)) - [[ $verbose_flag -gt 1 && $quiet_flag -eq 0 ]] && printf "\033[0;36m[PREP-TEST] Skip errtest \"$FILE\" (at $(basename "$test_fp")), not an executable.\e[0m\n" >&2 + [[ $verbose_flag -ge 4 && $quiet_flag -eq 0 ]] && log_cl "[PREP-TEST] Skip errtest \"$FILE\" (at $(basename "$test_fp")), not an executable." debug >&2 continue } fi @@ -369,26 +563,26 @@ function echo_tests_info { set_supported_tests "$kazoj_dir" 2>/dev/null echoed_cases_dir="${tests_info[0]}" echoed_errors_dir="${tests_info[1]}" - printf "\033[1;33m[DEBUG] Tests dir is: ( $kazoj_dir ).\e[0m\n" >&2 - printf "\033[1;33m[DEBUG] Cases dir is: ( $echoed_cases_dir ).\e[0m\n" >&2 - printf "\033[1;33m[DEBUG] ( $count_tests_names ) cases ready.\e[0m\n" >&2 + log_cl "Tests dir is: ( $kazoj_dir )." debug >&2 + log_cl "Cases dir is: ( $echoed_cases_dir )." debug >&2 + log_cl "( $count_tests_names ) cases ready." debug >&2 if [[ $big_list_flag -gt 0 ]] ; then { for i in $(seq 0 $(($count_tests_names-1))) ; do { - printf "\033[1;33m[DEBUG] ( ${read_tests_files[$i]} ).\e[0m\n" >&2 + log_cl "( ${read_tests_files[$i]} )." debug >&2 } done } fi - printf "\033[1;33m[DEBUG] Errors dir is: ( $echoed_errors_dir ).\e[0m\n" >&2 - printf "\033[1;33m[DEBUG] ( $count_errortests_names ) error cases ready.\e[0m\n" >&2 + log_cl "Errors dir is: ( $echoed_errors_dir )." debug >&2 + log_cl "( $count_errortests_names ) error cases ready." debug >&2 if [[ $big_list_flag -gt 0 ]] ; then { for i in $(seq 0 $(($count_errortests_names-1))) ; do { - printf "\033[1;33m[DEBUG] ( ${read_errortests_files[$i]} ).\e[0m\n" >&2 + log_cl "( ${read_errortests_files[$i]} )." debug >&2 } done } fi - printf "\033[1;33m[DEBUG] ( $tot_tests ) total tests ready.\e[0m\n" >&2 + log_cl "( $tot_tests ) total tests ready." debug >&2 #echo "$count_tests_infos" #echo "test info array contents are: ( ${tests_info[@]} )" >&2 } @@ -396,21 +590,21 @@ function echo_tests_info { function echo_othermode_tags { #Print remaining read versions not available in current mode if [[ $base_mode_flag -gt 0 ]] ; then { - mode_txt="\033[1;34mgit\e[0m" + mode_txt="git" printf " ( $count_git_versions ) supported tags when running in ( $mode_txt ) mode.\n" printf " Run again in ( $mode_txt ) mode to use them.\n" for i in $(seq 0 $(($count_git_versions-1))); do { (( $i % 4 == 0)) && [[ $i -ne 0 ]] && printf "\n" - printf " \033[0;33m${read_git_tags[i]}\e[0m" + printf " ${read_git_tags[i]}" } done } else { - mode_txt="\033[1;31mbase\e[0m" + mode_txt="base" printf " ( $count_base_versions ) supported tags when running in ( $mode_txt ) mode.\n" printf " Run again in ( $mode_txt ) mode to use them.\n" for i in $(seq 0 $(($count_base_versions-1))); do { (( $i % 4 == 0)) && [[ $i -ne 0 ]] && printf "\n" - printf " \033[0;33m${read_base_tags[i]}\e[0m" + log_cl " ${read_base_tags[i]}" info blue } done } @@ -419,12 +613,12 @@ function echo_othermode_tags { } function echo_supported_tags { - mode_txt="\033[1;34mgit\e[0m" - [[ $base_mode_flag -gt 0 ]] && mode_txt="\033[1;31mbase\e[0m" + mode_txt="git" + [[ $base_mode_flag -gt 0 ]] && mode_txt="base" printf " ( $tot_vers ) supported tags for current mode ( $mode_txt ).\n" for i in $(seq 0 $(($tot_vers-1))); do { #Print currently supported versions (only ones conforming to mode) (( $i % 4 == 0)) && [[ $i -ne 0 ]] && printf "\n" - printf " \033[1;32m${supported_versions[i]}\e[0m" + log_cl " ${supported_versions[i]}" info blue } done printf "\n" @@ -435,8 +629,8 @@ function git_mode_check { #Check if we're inside a repo git rev-parse --is-inside-work-tree 2>/dev/null 1>&2 is_git_repo="$?" - [[ $is_git_repo -gt 0 ]] && printf "\n\033[1;31m[ERROR] Not running in a git repo. Try running with -B to use base mode.\e[0m\n\n" && exit 1 - [[ $verbose_flag -gt 0 ]] && printf "\033[1;34m[MODE] Running in git mode.\e[0m\n" >&2 + [[ $is_git_repo -gt 0 ]] && log_cl "Not running in a git repo. Try running with -B to use base mode.\n" error && exit 1 + [[ $verbose_flag -gt 3 ]] && log_cl "[MODE] Running in git mode." info >&2 #Check if status is clean if output=$(git status --untracked-files=no --porcelain) && [ -z "$output" ]; then return 0 @@ -446,88 +640,60 @@ function git_mode_check { } function amboso_help { - amboso_usage - printf "Arguments: - - [-D ...] BINDIR Sets directory used to host tags - - [-K ...] TESTDIR Sets directory used to host tests - - [-S ...] SOURCENAME Sets name for target main source - - [-E ...] EXECNAME Sets name for target executable - - [-M ...] MAKETAG Sets minimum tag for using make as build/clean step - - [-C ...] CONFIG_FILE Filename for ./configure args for automake - - [-G ...] C_HEADER_DIR Sets desidered output directory for C header of specified version - - [-tgBT] mode Sets run mode - - Building: - - -g git mode (Default) - - -B base mode (Expects a full source copy of every tag. Not recommended.) - - Testing: - - -T test mode (Tests TAG_QUERY) - - -t test macro (Recurses as -T\"\$PASSED_FLAGS\" on all tests) - - Extra: - - -x stego parser (Runs amboso as stego parser) - - -V <[0-3]> Set verbose level - - Optional: - - -l Lint (Only lint the stego file) - -L Lint (Only lint the stego file) - - [-bripd] operation Combined operations on current tag. - - The operation changes semantics in test mode. - - In the order they are consumed from a top call: - - -i init (Recurses as -b\"\$MODE_FLAG\"\"\$PASSED_FLAGS\" on all tags for current build mode) - (TEST: record all test results) - - -b build Build TAG_QUERY - (TEST: record TAG_QUERY test results. If using -t for the macro, it's the same as -i) - - -r run Run TAG_QUERY (ATM unused in test mode) - - -d delete Delete TAG_QUERY (ATM unused in test mode) - - -p purge (Recurses as -b\"\$MODE_FLAG\"\"\$PASSED_FLAGS\" on all tags for current build mode) - - [-hHvVlLqc] info Change text output for the program. - - -hH help Prints help info - -v version Prints current version and quits - -lL list Lists all valid tags (-L ignores current build mode to check for tags) - -q quiet Less output (useful but not well implemented, recommended on recursive calls) - -s silent Way less output (Some output expected on stderr before the flag is applied) - -c control Output dotfile \'amboso_cfg.dot\' while running. - -w watch Always display timers regardless of verbosity. - -X experimental Ignore the result of git_mode_check, which would stop git mode runs early when git status is not clean. - -Y [...] START_TIME Set start time of the program. - -W Warranty Prints warranty information, as per GPL-3.0 license. - - [...] TAG_QUERY Ask a tag for current mode - - Reports if target executable name for TAG_QUERY was found at BINDIR/vTAG_QUERY/EXECNAME.\n" - + amboso_usage + amboso_help_string="Options: + -D Specify the directory to host tags [default: ./bin] + -K Specify the directory to host tests + -S Specify the source name + -E Specify the target executable name + -M Specify min tag using make as build/clean step + -G Generate anvil C header for passed dir + -x Act as stego linter for passed file + -T (test) Specify test mode + -B (base) Specify base mode + -g (git) Specify git mode + -t (testmacro) Specify test macro mode + -i (init) Build all tags for current mode + -p (purge) Delete binaries for all tags for current mode + -d (delete) Delete binary for passed tag + -b (build) Build binary for passed tag + -r (run) Run binary for passed tag + -l (list) Print supported tags for current mode + -L (list-all) Print supported tags for all modes + -q (quiet) Less output + -s (silent) Almost no output + -V More output [default: 3] + -w (watch) Report timer + -v (version) Print current version and quit + -W (warranty) Print warranty info and quit + -X (no-gitcheck) Ignore git mode checks + -J (logged) Output to log file + -P (no-color) Disable color output + -F (force) Enable force build + -R (no-rebuild) Disable calling make rebuild + -C Pass configuration file for ./configure arguments + -h (help) Print help + -Y Set start time of the program + -z (pack) Run \"make pack\" + -c (control-flow) Output dotfile \'amboso_cfg.dot\' while running + -H (bighelp) Print more help" + printf "%s\n" "$amboso_help_string" } function amboso_usage { - printf "Usage: $(basename "$prog_name") [(-D|-K|-M|-S|-E|-G|-C|-x|-V|-Y) ...ARGS] [-TBtg] [-bripd] [-hHvlLqcwXW] [TAG_QUERY]\n" - printf " Query for a build version ( or stego files parser, with -x).\n" + printf "Usage: amboso [OPTIONS] [TAG] [COMMAND]\n" + printf " Build tool wrapping make and git tags\n" + printf " Run with -H for more info about options.\n\n" + printf "Commands: + test does testing things + build Tries building latest tag + init Prepare a new anvil project + version Prints invil version + help Print this message or the help of the given subcommand(s)\n" + + printf "Arguments: + [TAG] Optional tag argument\n" + printf "Example usage: $(basename "$prog_name") [(-D|-K|-M|-S|-E|-G|-C|-x|-V|-Y) ] [-TBtg] [-bripd] [-hHvlLqcwXWPJRF] [TAG]\n" } function escape_colorcodes_tee { @@ -561,10 +727,10 @@ function record_test { #echo "r: $res" >> "$tmp_stdout" escape_colorcodes_tee "$tmp_stdout" "$tfp.stdout" escape_colorcodes_tee "$tmp_stderr" "$tfp.stderr" - rm -f "$tmp_stdout" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($tmp_stdout). Why?\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$tmp_stdout\".\e[0m\n" >&2 - rm -f "$tmp_stderr" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($tmp_stderr). Why?\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$tmp_stderr\".\e[0m\n" >&2 + rm -f "$tmp_stdout" || log_cl "Failed removing tmpfile ($tmp_stdout). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$tmp_stdout\"." info >&2 + rm -f "$tmp_stderr" || log_cl "Failed removing tmpfile ($tmp_stderr). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$tmp_stderr\"." info >&2 } function run_test { @@ -587,9 +753,9 @@ function delete_test { res="$?" if [[ $res -eq 0 ]]; then { - printf "\033[0;32m[TEST] Deleted $tfp.\e[0m\n" >&2 + log_cl "[TEST] Deleted $tfp." info >&2 } else { - printf "\033[1;31m[TEST] Failed deleting $tfp. How?\e[0m\n" >&2 + log_cl "[TEST] Failed deleting $tfp. How?" error >&2 } fi } @@ -615,14 +781,14 @@ lex_stego_file() { ############################################################################ # if [[ ! -f $1 ]] ; then { - printf "\033[1;31m[ERROR] ${FUNCNAME[0]}(): \"$1\" is not a valid file.\033[0m\n." + log_cl "${FUNCNAME[0]}(): \"$1\" is not a valid file." error exit 8 } fi input_file="$1" # Check if awk is available if ! command -v awk > /dev/null; then - printf "\033[1;31m[CRITICAL] Error: awk is not installed. Please install awk before running this script.\033[0m\n" + log_cl "[CRITICAL] Error: awk is not installed. Please install awk before running this script." error exit 9 fi @@ -644,10 +810,10 @@ lex_stego_file() { current_scope=gensub(/\s*$/, "", "g", a[1]) scopes[current_scope]++ } else { - print "\033[1;31m[LINT]\033[0m Invalid header: \033[1;31m" $0 "\033[0m" > "/dev/stderr" + print "[LINT] Invalid header: " $0 "" > "/dev/stderr" error_flag=1 } - } else if ($0 ~ /^"?[^"A-Z=\[\]_\$\\\/{}]+"? *= *"[^=\[\]\${}]+"$/) { + } else if ($0 ~ /^"?[^"=\[\]_\$\\\/{}]+"? *= *"[^=\[\]\${}]+"$/) { # Check if the line is a valid variable assignment split($0, parts, "=") @@ -660,7 +826,7 @@ lex_stego_file() { # Check if left side contains disallowed characters if (index(variable, " ") > 0 || (index(variable, "#") > 0 && index(variable, "\"") == 0)) { - print "\033[1;31m[LINT]\033[0m Invalid left side (contains spaces or disallowed characters): \033[1;31m" variable "\033[0m" > "/dev/stderr" + print "[LINT] Invalid left side (contains spaces or disallowed characters): " variable "" > "/dev/stderr" error_flag=1 next } @@ -692,13 +858,13 @@ lex_stego_file() { # This is a comment-only line and we can ignore it next } else { - print "\033[1;31m[LINT]\033[0m Invalid line: \033[1;31m" $0 "\033[0m" > "/dev/stderr" + print "[LINT] Invalid line: " $0 "" > "/dev/stderr" error_flag=1 } } } END { if (error_flag == 1) { - print "\033[1;31m[LEX]\033[0m Errors while lexing." > "/dev/stderr" + print "[LEX] Errors while lexing." > "/dev/stderr" } else { # Print each scope and its variable-value pairs for (scope in scopes) { @@ -737,7 +903,7 @@ lint_stego_file() { #Try lexing input file. If verbose is 1, print the lexed tokens. #If lex output is empty, return 1. if [[ ! -f $1 ]] ; then { - printf "\033[1;31m[ERROR] ${FUNCNAME[0]}(): \"$1\" is not a valid file.\033[0m\n." + log_cl "${FUNCNAME[0]}(): \"$1\" is not a valid file." error exit 8 } fi @@ -748,7 +914,7 @@ lint_stego_file() { lex_output="$(lex_stego_file "$input")" [[ $verbose -eq 1 ]] && printf "$lex_output\n" if [[ -z "$lex_output" ]]; then - printf "\033[1;31m[CHECK]\033[0m Errors occurred during lexing.\n" + log_cl "[CHECK] Errors occurred during lexing." error return 1 fi return 0 @@ -759,7 +925,7 @@ try_parsing_stego() { # Then, if the lint was successful, tries parsing the lexed tokens. # Upon return, arrays "scopes", "variables", "values" are set. if [[ ! -f $1 ]] ; then { - printf "\033[1;31m[ERROR] ${FUNCNAME[0]}(): \"$1\" is not a valid file.\033[0m\n." + log_cl "${FUNCNAME[0]}(): \"$1\" is not a valid file." error exit 8 } fi @@ -771,7 +937,7 @@ try_parsing_stego() { parse_res="$?" return "$parse_res" } else { - printf "\033[1;31m[PARSE]\033[0m Lint failed.\n" + log_cl "[PARSE] Lint failed." error return 1 } fi @@ -780,7 +946,7 @@ try_parsing_stego() { bash_gulp_stego() { # Try gulping the "scopes", "variables" and "values" bash arrays from parsing the passed file if [[ ! -f $1 ]] ; then { - printf "\033[1;31m[ERROR] ${FUNCNAME[0]}(): \"$1\" is not a valid file.\033[0m\n" + log_cl "${FUNCNAME[0]}(): \"$1\" is not a valid file." error exit 8 } fi @@ -791,12 +957,12 @@ bash_gulp_stego() { try_parsing_stego "$input" "$verbose" parse_res="$?" if [[ $parse_res -eq 0 ]]; then { - [[ $verbose -eq 1 ]] && printf "\033[1;32m[SUCCESS] Parsed file \"$filename\"\033[0m\n" - [[ $verbose -eq 1 ]] && printf "\033[1;36m[Lexed variables]\033[0m { ${variables[*]} }\n\n" - [[ $verbose -eq 1 ]] && printf "\033[1;35m[Lexed values]\033[0m { ${values[*]} }\n" + [[ $verbose -eq 1 ]] && log_cl "[SUCCESS] Parsed file \"$filename\"" info + [[ $verbose -eq 1 ]] && log_cl "[Lexed variables] { ${variables[*]} }\n" info magenta + [[ $verbose -eq 1 ]] && log_cl "[Lexed values] { ${values[*]} }" info blue return 0 } else { - printf "\033[1;31m[ERROR]\033[0m ${FUNCNAME[0]}(): Failed parsing file { \033[1;34m$1\033[0m }\n" + log_cl "${FUNCNAME[0]}(): Failed parsing file { $1 }\n" error return 1 } fi @@ -861,7 +1027,7 @@ set_amboso_stego_info() { bash_gulp_stego "$stego_file" 0 #&& print_amboso_stego_scopes if [[ ! $? -eq 0 ]]; then { - printf "\033[1;31m[ERROR] Failed parsing stego file at \"$stego_file\".\033[0m\n" + log_cl "Failed parsing stego file at \"$stego_file\"." error exit 7 } fi @@ -915,9 +1081,9 @@ set_amboso_stego_info() { fi } elif [[ $scope = "versions" ]] ; then { tag="$(printf -- "$variable\n" | cut -f2 -d'_')" - if [[ $tag == -* ]] ; then { + if [[ $tag == B* ]] ; then { [[ $verbose -gt 0 ]] && printf "ANVIL_BASE_VERSION: {$tag}\n" - cut_tag="$(printf -- "$tag\n" | cut -f2 -d'-')" + cut_tag="$(printf -- "$tag\n" | cut -f2 -d'B')" read_base_tags[base_tags_count]="$cut_tag" #printf "${read_base_tags[base_tags_count]} at {$base_tags_count}\n" base_tags_count=$(($base_tags_count+1)) @@ -949,39 +1115,66 @@ set_amboso_stego_info() { done count_source_infos="${#sources_info[@]}" if [[ -z $exec_entrypoint ]] ; then { - printf "\033[1;31m[ERROR] Missing binary name.\033[1;31m\n" + log_cl "Missing binary name." error exit 1 } fi if [[ -z $source_name ]] ; then { - printf "\033[1;31m[ERROR] Missing source name.\033[1;31m\n" + log_cl "Missing source name." error exit 2 } fi if [[ -z $makefile_version ]] ; then { - printf "\033[1;31m[ERROR] Missing first version using make.\033[1;31m\n" + log_cl "Missing first version using make." error exit 3 } fi if [[ -z $use_automake_version ]] ; then { - printf "\033[1;31m[ERROR] Missing first version using automake.\033[1;31m\n" + log_cl "Missing first version using automake." error exit 4 } fi if [[ -z $use_autoconf_version ]] ; then { - printf "\033[1;31m[ERROR] Missing first version using autoconf.\033[1;31m\n" + log_cl "Missing first version using autoconf." error exit 5 } fi if [[ -z $kazoj_dir ]] ; then { - printf "\033[1;31m[ERROR] Missing tests dir.\033[1;31m\n" + log_cl "Missing tests dir." error exit 6 } fi - [[ $verbose -gt 0 ]] && printf "\033[1;34m[INFO] Read {$count_source_infos} amboso params.\033[0m\n" + [[ $verbose -gt 0 ]] && log_cl "Read {$count_source_infos} amboso params." info count_git_versions="${#read_git_tags[@]}" count_base_versions="${#read_base_tags[@]}" + strict_regex='^([1-9][0-9]*|0)\.([1-9][0-9]*|0)\.([1-9][0-9]*|0)$' + full_regex='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$' + + for gt in "${read_git_tags[@]}" ; do { + if [[ ! "$gt" =~ $strict_regex ]] ; then { + if [[ "$gt" =~ $full_regex ]] ; then { + log_cl "Pre-release and build metadata is not allowed for strict semver." warn + } + fi + log_cl "Invalid key: {$gt}" error + exit 1 + } + fi + } + done + for bt in "${read_base_tags[@]}" ; do { + if [[ ! "$bt" =~ $strict_regex ]] ; then { + if [[ "$gt" =~ $full_regex ]] ; then { + log_cl "Pre-release and build metadata is not allowed for strict semver." warn + } + fi + log_cl "Invalid key: {$bt}" error + exit 1 + } + fi + } + done # Sort the SemVer tags read_git_tags=($(printf "%s\n" "${read_git_tags[@]}" | sort -V)) read_base_tags=($(printf "%s\n" "${read_base_tags[@]}" | sort -V)) @@ -1002,9 +1195,17 @@ set_amboso_stego_info() { done } fi - tot_vers=${#supported_versions[@]} - latest_version="${supported_versions[tot_vers-1]}" - [[ $verbose -gt 0 ]] && printf "\033[1;34m[INFO] Read {$tot_vers} tags.\033[0m\n" + tot_vers="${#supported_versions[@]}" + latest_idx=0 + if [[ "$tot_vers" -eq 0 ]] ; then { + log_cl "Empty supported versions map." warn + latest_idx=0 + } else { + latest_idx="$(( $tot_vers - 1))" + } + fi + latest_version="${supported_versions[latest_idx]}" + [[ $verbose -gt 0 ]] && log_cl "Read {$tot_vers} tags." info return 0 } @@ -1014,10 +1215,10 @@ amboso_parse_args() { AMBOSO_LVL_REC=$(($AMBOSO_LVL_REC+1)) # check recursion if [[ "${AMBOSO_LVL_REC}" -le "3" ]]; then - PARENT_COMMAND=$(ps -o comm= $PPID) - [[ $PARENT_COMMAND = "$prog_name" ]] && printf "Unexpected result while checking amboso recursion level.\n" && exit 1 + PARENT_COMMAND="$(ps -o comm= $PPID)" + [[ "$PARENT_COMMAND" = "$prog_name" ]] && log_cl "Unexpected result while checking amboso recursion level." error && exit 1 else - printf "\n[AMBOSO] Exceeded depth for recursion ( nested ${AMBOSO_LVL_REC} times).\n\n" + log_cl "[AMBOSO] Exceeded depth for recursion ( nested ${AMBOSO_LVL_REC} times).\n" error echo_timer "$amboso_start_time" "Excessive recursion" "1" exit 69 fi @@ -1045,13 +1246,13 @@ amboso_parse_args() { #Prepare flag values to default value - amboso_version="amboso version $amboso_currvers" + amboso_version="amboso, v$amboso_currvers" purge_flag=0 run_flag=0 #By default we don't run the binary build_flag=0 delete_flag=0 init_flag=0 - verbose_flag=0 + verbose_flag=3 quiet_flag=0 dir_flag=0 exec_entrypoint= #By default the value is empty @@ -1091,13 +1292,28 @@ amboso_parse_args() { queried_stego_filepath="" pass_autoconf_arg_flag=0 autoconf_arg_file="" + allow_color_flag=1 + do_filelog_flag=0 + enable_make_rebuild_flag=1 + force_build_flag=0 - while getopts "A:M:S:E:D:K:G:Y:x:V:C:wBgbpHhrivdlLtTqsczUXW" opt; do + while getopts "A:M:S:E:D:K:G:Y:x:V:C:wBgbpHhrivdlLtTqsczUXWPJRF" opt; do case $opt in + F ) + force_build_flag=1 + ;; + R ) + enable_make_rebuild_flag=0 + ;; + P ) + allow_color_flag=0 + ;; + J ) + do_filelog_flag=1 + ;; C ) pass_autoconf_arg_flag=1 autoconf_arg_file="$OPTARG" - [[ -f "$autoconf_arg_file" ]] || { printf "\033[1;31m[ERROR]\033[0m Invalid file for configure argument: {\033[1;33m%s\033[0m}\n" "$autoconf_arg_file" ; exit 1 ; } ; ;; x ) be_stego_parser_flag=1 @@ -1113,7 +1329,7 @@ amboso_parse_args() { gen_C_headers_flag=1 gen_C_headers_destdir="$OPTARG" if [[ ! -d $gen_C_headers_destdir ]] ; then { - printf "\033[1;33m[WARN] ($gen_C_headers_destdir) was not a valid directory.\e[0m\n" + log_cl "($gen_C_headers_destdir) was not a valid directory." warn gen_C_headers_set=1 #TODO: this reads horribly. It's a patch to allow the called function to still be called, since now it will try to make the directory } else { gen_C_headers_set=1 @@ -1151,7 +1367,7 @@ amboso_parse_args() { ;; D ) dir_flag=1 - milestones_dir="$OPTARG" + scripts_dir="$OPTARG" ;; K ) testdir_flag=1 @@ -1192,12 +1408,13 @@ amboso_parse_args() { ;; V ) requested_lvl="$OPTARG" - verbose_lvl_re='^[0-9]$' - if ! [[ $requested_lvl =~ $verbose_lvl_re ]]; then { - printf "\033[1;31m[ERROR]\033[0m Invalid verbose lvl: {%s}\n" "$requested_lvl" + verbose_lvl_re='^[0-5]$' + if ! [[ "$requested_lvl" =~ $verbose_lvl_re ]]; then { + log_cl "Invalid verbose lvl: {$requested_lvl}" error + amboso_help return 1 } else { - verbose_flag="$requested_lvl" + verbose_flag="$( printf "$requested_lvl\n" | awk -F" " '{print $1}')" } fi ;; @@ -1223,19 +1440,47 @@ amboso_parse_args() { init_flag=1 ;; \? ) - printf "Invalid option: -$OPTARG. Run with -h for help.\n" >&2 + log_cl "Invalid option: -$OPTARG. Run with -h for help." error >&2 exit 1 ;; : ) - printf "Option -$OPTARG requires an argument. Run with -h for help.\n" >&2 + log_cl "Option -$OPTARG requires an argument. Run with -h for help." error >&2 exit 1 ;; esac tot_opts=$OPTIND done - if [[ $quiet_flag -eq 0 && "${AMBOSO_LVL_REC}" -lt 3 ]]; then { - printf "amboso, version $amboso_currvers\nCopyright (C) 2023 jgabaut\n\n This program comes with ABSOLUTELY NO WARRANTY; for details type \`$(basename "$prog_name") -W\`.\n This is free software, and you are welcome to redistribute it\n under certain conditions; see file \`LICENSE\` for details.\n\n Full source is available at https://github.com/jgabaut/amboso\n\n" + if [[ $version_flag -eq 1 ]] ; then { + echo_amboso_version_short + echo_timer "$amboso_start_time" "Version flag, 1" "2" + exit 0 + } elif [[ $version_flag -gt 1 ]] ; then { + echo_amboso_version + echo_timer "$amboso_start_time" "Version flag, >1" "2" + exit 0 + } + fi + + if [[ "$pass_autoconf_arg_flag" -gt 0 ]] ; then { + [[ -f "$autoconf_arg_file" ]] || { log_cl "Invalid file for configure argument: {$autoconf_arg_file}" error ; exit 1 ; } ; + } + fi + + CC="${CC:-gcc}" + CFLAGS="${CFLAGS:-}" + AMBOSO_COLOR="$allow_color_flag" + AMBOSO_LOGGED="$do_filelog_flag" + export AMBOSO_COLOR="${AMBOSO_COLOR:-0}" + export AMBOSO_LOGGED="${AMBOSO_LOGGED:-0}" + if [[ $quiet_flag -eq 0 && "${AMBOSO_LVL_REC}" -lt 2 ]]; then { + echo_amboso_splash "$amboso_currvers" "$(basename "$prog_name")" + awk_check="$(awk -W version 2>/dev/null | grep mawk)" + if [[ ! -z "$awk_check" ]] ; then { + log_cl "awk seems to be mawk. The script may fail unexpectedly. See issue: https://github.com/jgabaut/amboso/issues/58" warn + } + fi + echo_invil_notice } fi if [[ $quiet_flag -eq 0 && $show_warranty_flag -gt 0 && "${AMBOSO_LVL_REC}" -eq 1 ]]; then { @@ -1252,8 +1497,11 @@ amboso_parse_args() { if [[ "${AMBOSO_LVL_REC}" -eq "1" ]]; then { if [[ "${BASH_VERSINFO:-0}" -lt "4" ]] ; then { - printf "\033[1;31m[WARN] Bash version: {$BASH_VERSION} is less than 4\e[0m\n\n" - printf "\033[1;31m[WARN] amboso may not work as expected.\n\n" + log_cl "Bash version: {$BASH_VERSION} is less than 4\n" warn + log_cl "amboso may not work as expected. See issue: https://github.com/jgabaut/amboso/issues/21\n" warn + } elif [[ "${BASH_VERSINFO:-0}" -eq "4" ]] ; then { + log_cl "Bash version: {$BASH_VERSION} is less than 5\n" warn + log_cl "amboso may not work as expected.\n" warn } fi } @@ -1272,13 +1520,13 @@ amboso_parse_args() { } fi - [[ $verbose_flag -gt 1 ]] && printf "\033[0;32m[PREP] Done getopts.\e[0m\n" >&2 - [[ $verbose_flag -gt 0 && ! $prog_name = "anvil" ]] && printf "\033[1;36m[AMBOZO]\e[0m Please, symlink me to \"anvil\".\n\n" >&2 + [[ $verbose_flag -ge 4 ]] && log_cl "[PREP] Done getopts." debug >&2 + [[ $verbose_flag -gt 3 && ! "$prog_name" = "anvil" ]] && log_cl "[AMBOZO] Please, symlink me to \"anvil\".\n" debug >&2 # Load functions from amboso_fn.sh #source_amboso_api - [[ $verbose_flag -gt 1 ]] && printf "\033[0;32m[PREP] Printing active flags:\e[0m\n" >&2 && echo_active_flags >&2 + [[ $verbose_flag -ge 4 ]] && log_cl "[PREP] Printing active flags:" debug >&2 && echo_active_flags >&2 trace_flag=0 trace_line="421" # Check env var to enable backtrace @@ -1286,25 +1534,25 @@ amboso_parse_args() { if [[ ${AMBOSO_TRACING} -gt 0 ]]; then { trace_line=0 trace_flag=1; - printf "\033[0;37m[TRACE] Tracing started.\e[0m\n" >&2 + log_cl "[TRACE] Tracing started." debug >&2 trap backtrace DEBUG ERR } else { : #echo "{No trace}" >&2 } fi - [[ $verbose_flag -gt 1 ]] && printf "\033[0;37m[PREP] Parent command is: ( $PARENT_COMMAND ).\e[0m\n" >&2 + [[ $verbose_flag -ge 4 ]] && log_cl "[PREP] Parent command is: ( $PARENT_COMMAND )." debug >&2 #Won't print call info for top level calls if [[ ${AMBOSO_LVL_REC} -gt 1 ]] ; then { #and 1+ nested test calls ( with -T, from -t calling -T) - [[ $quiet_flag -eq 0 && $verbose_flag -gt 0 ]] && printf "\033[1;34m[AMBOSO] Amboso depth: ( $((${AMBOSO_LVL_REC}-1)) )\e[0m\n" + [[ $quiet_flag -eq 0 && $verbose_flag -gt 3 ]] && log_cl "[AMBOSO] Amboso depth: ( $((${AMBOSO_LVL_REC}-1)) )" debug if [[ $AMBOSO_LVL_REC -lt 2 ]] ; then { printf "\n\n args: (\"$*\")\n" >&2 echo_active_flags >&2 } elif [[ $AMBOSO_LVL_REC -gt 2 ]] ; then { - [[ $test_info_was_set -eq 1 ]] && printf "[AMBOSO] Deep recursion (>1), are you calling \"$prog_name\" in a test? ;)\n" >&2 + [[ $test_info_was_set -eq 1 ]] && log_cl "[AMBOSO] Deep recursion (>1), are you calling \"$prog_name\" in a test? ;)" debug >&2 #[[ $small_test_mode_flag -gt 0 ]] && echo "[ERROR] Can't proceed and macro -t for -T on all tags." && exit 69 #[[ $test_mode_flag -gt 0 ]] && echo "[ERROR] Can't proceed with test mode." && exit 69 } @@ -1319,7 +1567,7 @@ amboso_parse_args() { if [[ $be_stego_parser_flag -eq 1 ]] ; then { filepath="$queried_stego_filepath" - [[ -f "$filepath" ]] || { printf "\033[1;31m[ERROR]\033[0m \"$filepath\" was not a valid file.\n" ; exit 1 ; } + [[ -f "$filepath" ]] || { log_cl "\"$filepath\" was not a valid file." error ; exit 1 ; } if [[ $big_list_flag -eq 1 ]] ; then { lex_stego_file "$filepath" @@ -1328,10 +1576,10 @@ amboso_parse_args() { lint_stego_file "$filepath" 0 # We call with verbose ($2) 0, and won't get the lexed tokens printed. lint_res="$?" if [[ $lint_res -eq 0 ]]; then { - printf "\033[1;36m[LINT]\033[0m { Success on: \"$filepath\" }\n" + log_cl "[LINT] { Success on: \"$filepath\" }" info exit 0 } else { - printf "\033[1;31m[LINT]\033[0m { Failure on: \"$filepath\" }\n" + log_cl "[LINT] { Failure on: \"$filepath\" }" error exit 1 } fi @@ -1346,26 +1594,15 @@ amboso_parse_args() { } fi - if [[ $version_flag -eq 1 ]] ; then { - echo_amboso_version_short - echo_timer "$amboso_start_time" "Version flag, 1" "2" - exit 0 - } elif [[ $version_flag -gt 1 ]] ; then { - echo_amboso_version - echo_timer "$amboso_start_time" "Version flag, >1" "2" - exit 0 - } - fi - - [[ "$verbose_flag" -gt 1 ]] && printf "\033[1;35m[AMBOSO] Current version: $amboso_currvers\e[0m\n\n" + [[ "$verbose_flag" -ge 4 ]] && log_cl "[AMBOSO] Current version: $amboso_currvers\n" info - [[ $quiet_flag -eq 0 && $verbose_flag -gt 0 ]] && for read_arg in "$@"; do { printf "[ARG] \"$read_arg\"\n" ; } ; done + [[ $quiet_flag -eq 0 && $verbose_flag -gt 3 ]] && for read_arg in "$@"; do { printf "[ARG] \"$read_arg\"\n" ; } ; done app "$(echo_node loaded_fn silence_check)" #We check if we have to silence all subsequent output if [[ ( $test_mode_flag -eq 0 && $small_test_mode_flag -eq 0 ) && $silent_flag -gt 0 ]] ; then { - printf "\033[1;33m[MODE]\e[0m Running in silent mode, will now suppress all output.\n\n" + log_cl "[MODE] Running in silent mode, will now suppress all output.\n" info echo_timer "$amboso_start_time" "Silent run, turning off outputs" "2" exec 3>&1 &>/dev/null printf "This output is going to dev null\n" @@ -1378,7 +1615,7 @@ amboso_parse_args() { if [[ $test_mode_flag -gt 0 ]] ; then { git_mode_flag=0 base_mode_flag=0 - printf "\033[1;33m[MODE] Running in test mode.\e[0m\n" >&2 + log_cl "[MODE] Running in test mode." info >&2 } fi @@ -1388,7 +1625,7 @@ amboso_parse_args() { #Default mode with no flags should be git mode if [[ $base_mode_flag -gt 0 ]] ; then { git_mode_flag=0 - printf "\033[1;31m[MODE] Running in base mode, expecting full source builds.\e[0m\n" >&2 + log_cl "[MODE] Running in base mode, expecting full source builds." debug >&2 } fi if [[ $git_mode_flag -gt 0 && $be_stego_parser_flag -eq 0 ]] ; then { @@ -1396,51 +1633,51 @@ amboso_parse_args() { git_mode_check git_mode_check_res="$?" if [[ $git_mode_check_res -eq 0 ]]; then { - [[ $verbose_flag -gt 0 ]] && printf "\033[1;33m[GIT] Status was clean.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[GIT] Status was clean." debug >&2 } else { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;31m[GIT] Status was not clean!\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[GIT] Status was not clean!" error >&2 if [[ $ignore_git_check_flag -eq 0 ]]; then { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;31m[AMBOSO] Aborting.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[AMBOSO] Quitting." error >&2 echo_timer "$amboso_start_time" "Dirty git status" "1" return 1 } fi - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;35m[AMBOZO] We ignore this and will waste time.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[AMBOZO] We ignore this and will waste time." info magenta >&2 } fi } fi #We always notify of missing -D argument - [[ ! $dir_flag -gt 0 ]] && milestones_dir="./bin/" && printf "\033[1;33m[DEBUG] No -D flag, using ( $milestones_dir ) for target dir. Run with -V to see more.\e[0m\n" >&2 #&& usage && exit 1 + [[ ! $dir_flag -gt 0 ]] && scripts_dir="./bin/" && log_cl "No -D flag, using ( $scripts_dir ) for target dir. Run with -V to see more." debug >&2 #&& usage && exit 1 #We always notify of missing -K argument, if in test mode if [[ $test_mode_flag -gt 0 && ! $testdir_flag -gt 0 ]] ; then { - set_amboso_stego_info "$milestones_dir/stego.lock" "$verbose_flag" + set_amboso_stego_info "$scripts_dir/stego.lock" "$verbose_flag" res="$?" - [[ $res -eq 0 ]] || printf "\033[0;33m[WARN]\e[0m Problems when doing set_amboso_stego_info($kazoj_dir).\n\n" + [[ $res -eq 0 ]] || log_cl "Problems when doing set_amboso_stego_info($kazoj_dir).\n" warn set_supported_tests "$kazoj_dir" res="$?" - [[ $res -eq 0 ]] || printf "\033[0;33m[WARN]\e[0m Problems when doing set_supported_tests($kazoj_dir).\n\n" + [[ $res -eq 0 ]] || log_cl "Problems when doing set_supported_tests($kazoj_dir).\n" warn kazoj_dir="$(pwd)/kazoj/" - [[ $quiet_flag -eq 0 ]] && printf "\033[1;33m[DEBUG] No -K flag, using ( $kazoj_dir ) for target dir. Run with -V to see more.\e[0m\n" >&2 #&& usage && exit 1 + [[ $quiet_flag -eq 0 ]] && log_cl "No -K flag, using ( $kazoj_dir ) for target dir. Run with -V to see more." debug >&2 #&& usage && exit 1 } fi if [[ $test_mode_flag -gt 0 && $test_info_was_set -gt 0 ]] ; then { if [[ $AMBOSO_LVL_REC -lt 3 ]] ; then { app "$(echo_node silence_check test_mode)" app "$(echo_node test_mode recursion_lt_3)" - printf "\033[1;32m[DEBUG] bone dir: ( $cases_dir )\e[0m\n" >&2 - printf "\033[1;32m kulpo dir: ( $errors_dir )\e[0m\n" >&2 #&& usage && exit 1 + log_cl "bone dir: ( $cases_dir )" debug >&2 + log_cl " kulpo dir: ( $errors_dir )" debug >&2 #&& usage && exit 1 } else { app "$(echo_node silence_check test_mode)" app "$(echo_node test_mode recursion_ge_3)" app "$(echo_node recursion_ge_3 end_node)" end_digraph - [[ ! -z $cases_dir ]] && printf "\033[1;32m[DEBUG] bone dir: ( $cases_dir )\e[0m\n" >&2 - [[ ! -z $errors_dir ]] && printf "\033[1;32m kulpo dir: ( $errors_dir )\e[0m\n" >&2 #&& usage && exit 1 - printf "\n\033[1;31m[PANIC] Running as \"$prog_name\" in test mode is not supported. Quitting with 69.\e[0m\n\n" #&& usage && exit 1 + [[ ! -z $cases_dir ]] && log_cl "bone dir: ( $cases_dir )" debug >&2 + [[ ! -z $errors_dir ]] && log_cl " kulpo dir: ( $errors_dir )" debug >&2 #&& usage && exit 1 + log_cl "[PANIC] Running as \"$prog_name\" in test mode is not supported. Quitting with 69.\n" error #&& usage && exit 1 echo_timer "$amboso_start_time" "Test calling \"$(basename "$prog_name")\" in test mode to run a test with..." "1" exit 69 #We return 69 and will check for this somewhere @@ -1451,17 +1688,17 @@ amboso_parse_args() { app "$(echo_node test_mode no_test_info)" if [[ $AMBOSO_LVL_REC -lt 3 ]] ; then { app "$(echo_node no_test_info recursion_lt_3)" - printf "\033[1;33m[DEBUG] bone dir (NO -K passed to this call): ( $cases_dir )\e[0m\n" >&2 - printf "\033[1;33m kulpo dir (NO -K passed to this amboso call): ( $errors_dir )\e[0m\n" >&2 #&& usage && exit 1 + log_cl "bone dir (NO -K passed to this call): ( $cases_dir )" debug >&2 + log_cl " kulpo dir (NO -K passed to this amboso call): ( $errors_dir )" debug >&2 #&& usage && exit 1 } else { app "$(echo_node no_test_info recursion_ge_3)" app "$(echo_node recursion_ge_3 end_node)" end_digraph #Deep case: we're running a test, calling a program that calls amboso in test mode. - printf "\033[1;33m[DEBUG] bone dir (NO -K passed to this call): ( $cases_dir )\e[0m\n" >&2 - printf "\033[1;33m kulpo dir (NO -K passed to this amboso call): ( $errors_dir )\e[0m\n" >&2 #&& usage && exit 1 + log_cl "bone dir (NO -K passed to this call): ( $cases_dir )" debug >&2 + log_cl " kulpo dir (NO -K passed to this amboso call): ( $errors_dir )" debug >&2 #&& usage && exit 1 - printf "\n\033[1;31m[PANIC] Running \"$(basename "$prog_name")\" using test mode in a program that will be called by test mode is not supported.\e[0m\n\n" >&2 #&& usage && exit 1 + log_cl "[PANIC] Running \"$(basename "$prog_name")\" using test mode in a program that will be called by test mode is not supported.\n" error >&2 #&& usage && exit 1 echo_timer "$amboso_start_time" "Test calling \"$(basename "$prog_name")\" in test mode to run a test with..." "1" exit 1 } @@ -1484,7 +1721,7 @@ amboso_parse_args() { amboso_usage printf "Try running with with -H for more info.\n\n" - #"$prog_name" -H -D "$milestones_dir" | less + #"$prog_name" -H -D "$scripts_dir" | less echo_timer "$amboso_start_time" "Show help" "2" exit 0 } @@ -1508,32 +1745,23 @@ amboso_parse_args() { fi #Syncpoint: we assert we know these names after this. WIP - - #TODO: check if scripts_dir is needed anywhere... why - scripts_dir="$milestones_dir" # MUST BE SET before checking for -S and -E - set_amboso_stego_info "$milestones_dir/stego.lock" "$verbose_flag" + set_amboso_stego_info "$scripts_dir/stego.lock" "$verbose_flag" if [[ ! $? -eq 0 ]] ; then { - printf "\033[1;31m[CRITICAL] Could not set amboso stego info.\033[0m\n" + log_cl "[CRITICAL] Could not set amboso stego info." error exit 1 } fi - # LEGACY - # set_supported_versions "$scripts_dir" # Might as well do it now - # set_source_info "$milestones_dir" - # kazoj_dir="${sources_info[3]}" #TODO: don't think this should be overwritten here if assigned earlier - # use_automake_version="${sources_info[4]}" - # set_tests_info "$kazoj_dir" set_supported_tests "$kazoj_dir" - if [[ $verbose_flag -gt 1 ]]; then { - printf "\033[1;36m[FETCH] Fetching remote tags\e[0m\n" >&2 + if [[ $verbose_flag -ge 4 ]]; then { + log_cl "[FETCH] Fetching remote tags" info >&2 echo_tag_info "$version" } fi - if [[ $verbose_flag -gt 1 ]]; then { #WIP - printf "\033[1;35m[VERB] SYNCPOINT: listing tag names\e[0m\n" >&2 + if [[ $verbose_flag -ge 4 ]]; then { #WIP + log_cl "[VERB] SYNCPOINT: listing tag names" info cyan >&2 echo_supported_tags >&2 echo_tests_info "$kazoj_dir" >&2 } @@ -1541,32 +1769,9 @@ amboso_parse_args() { #If we're in test mode and test dir was not set, we check if "./kazoj" is a directory and use that. If it isn't, we may get the name from stego.lock. If that is not a directory, we quit immediately. if [[ -z $kazoj_dir && $test_mode_flag -gt 0 ]] ; then { - #TODO Do we need to do further checks for amboso_testflag_version? - printf "\033[1;31m[ERROR] kazoj_dir was not set, while in test mode.\033[0m\n" + log_cl "kazoj_dir was not set, while in test mode." error exit 3 - - # LEGACY - # - #if [[ "$amboso_currvers" > "$amboso_testflag_version" || "$amboso_currvers" = "$amboso_testflag_version" ]] ; then { - # if [[ -d "./kazoj" ]]; then { - # kazoj_dir="./kazoj" - # set_tests_info "$kazoj_dir" - # set_supported_tests "$kazoj_dir" - # [[ $quiet_flag -eq 0 || $verbose_flag -gt 0 ]] && printf "\033[1;33m[DEBUG] No -K flag on a test run (amboso > $amboso_testflag_version), using \"./kazoj\" as tests dir.\e[0m\n" >&2 - # } else { - # [[ $quiet_flag -eq 0 || $verbose_flag -gt 0 ]] && printf "\033[1;33m[DEBUG] No -K flag on a test run (amboso > $amboso_testflag_version), reading stego.lock.\e[0m\n" >&2 - # set_supported_tests "$kazoj_dir" - # [[ $quiet_flag -eq 0 || $verbose_flag -gt 0 ]] && printf "\033[1;33m[DEBUG] No -K flag on a test run (amboso > $amboso_testflag_version), reading stego.lock.\e[0m\n" >&2 - # } - # fi - #} else { - # printf "\033[1;31m[ERROR] No -K flag on a test run, amboso version is < ($amboso_testflag_version).\n Quitting.\e[0m\n" #>&2 - # echo_timer "$amboso_start_time" "No -K on test run" "3" - # exit 0 - #} - #fi - # } fi @@ -1599,46 +1804,46 @@ amboso_parse_args() { #If version for makefile support was not specified, we notify in verbose mode or not in quiet mode if [[ -z $makefile_version ]] ; then { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;31m[ASSERT-FALSE] makefile_version was empty.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[ASSERT-FALSE] makefile_version was empty" error >&2 exit 1 } fi #We notify of missing -E argument if we're in verbose mode or not in quiet mode if [[ -z $exec_entrypoint ]] ; then { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;31m[ASSERT-FALSE] exec_entrypoint was empty.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[ASSERT-FALSE] exec_entrypoint was empty." error >&2 exit 1 } fi #We notify of missing -S argument if we're in verbose mode or not in quiet mode if [[ -z $source_name ]] ; then { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;31m[ASSERT-FALSE] source_name was empty.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[ASSERT-FALSE] source_name was empty." error >&2 exit 1 } fi #We notify of missing -A argument if we're in verbose mode or not in quiet mode if [[ -z $use_autoconf_version ]] ; then { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[1;31m[ASSERT-FALSE] use_autoconf_version was empty.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && log_cl "[ASSERT-FALSE] use_autoconf_version was empty." error >&2 exit 1 } fi #Display needed values if in verbose mose - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && [[ ! $dir_flag -gt 0 ]] && printf "\033[0;32m[INFO] Using target dir: ( $scripts_dir ).\e[0m\n" >&2 - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && [[ ! $exec_was_set -gt 0 ]] && printf "\033[0;32m[INFO] Using target bin: ( $exec_entrypoint ).\e[0m\n" >&2 - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && [[ ! $sourcename_was_set -gt 0 ]] && printf "\033[0;32m[INFO] Using source file name: ( $source_name ).\e[0m\n" >&2 - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && [[ ! $vers_make_flag -gt 0 ]] && printf "\033[0;32m[INFO] Using tag for make support: ( $makefile_version ) as first tag compiled with make.\e[0m\n" >&2 - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && [[ ! $vers_autoconf_flag -gt 0 ]] && printf "\033[0;32m[INFO] Using tag for automake support: ( $use_autoconf_version ) as first tag compiled with automake.\e[0m\n" >&2 - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && [[ $test_mode_flag -gt 0 && ! $test_info_was_set -gt 0 ]] && printf "\033[0;32m[INFO] Using tests dir: ( $kazoj_dir ).\e[0m\n" >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && [[ ! $dir_flag -gt 0 ]] && log_cl "Using target dir: ( $scripts_dir )." info >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && [[ ! $exec_was_set -gt 0 ]] && log_cl "Using target bin: ( $exec_entrypoint )." info >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && [[ ! $sourcename_was_set -gt 0 ]] && log_cl "Using source file name: ( $source_name )." info >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && [[ ! $vers_make_flag -gt 0 ]] && log_cl "Using tag for make support: ( $makefile_version ) as first tag compiled with make." info >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && [[ ! $vers_autoconf_flag -gt 0 ]] && log_cl "Using tag for automake support: ( $use_autoconf_version ) as first tag compiled with automake." info >&2 + [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] && [[ $test_mode_flag -gt 0 && ! $test_info_was_set -gt 0 ]] && log_cl "Using tests dir: ( $kazoj_dir )." info >&2 #Check if we are doing init and we're not in test mode #Which means we want to build all tags #TODO: Why is this checked before determining if we're doing build mode or test mode? if [[ $init_flag -gt 0 && $test_mode_flag -eq 0 && $small_test_mode_flag -eq 0 ]] ; then { - if [[ $quiet_flag -eq 0 && $verbose_flag -gt 1 ]]; then { #WIP - printf "\033[1;35m[VERB] Init mode (no -tT): build all tags\e[0m\n" >&2 + if [[ $quiet_flag -eq 0 && $verbose_flag -ge 4 ]]; then { #WIP + log_cl "[VERB] Init mode (no -tT): build all tags" info >&2 echo_supported_tags >&2 } fi @@ -1661,31 +1866,41 @@ amboso_parse_args() { packm="" ignore_gitcheck="" showtimem="" + plainm="" + loggedm="" + configm="" + norebuildm="" + forcebuildm="" + [[ $force_build_flag -gt 0 ]] && forcebuildm="F" + [[ $enable_make_rebuild_flag -eq 0 ]] && norebuildm="R" + [[ $pass_autoconf_arg_flag -gt 0 ]] && configm="-C $autoconf_arg_file" + [[ $do_filelog_flag -gt 0 ]] && loggedm="J" + [[ $allow_color_flag -le 0 ]] && plainm="P" [[ $ignore_git_check_flag -gt 0 ]] && ignore_gitcheck="X" [[ $show_time_flag -gt 0 ]] && showtimem="w" [[ $pack_flag -gt 0 ]] && packm="z" #Pass pack op mode [[ $silent_flag -gt 0 ]] && silentm="s" #Pass silent mode - [[ $verbose_flag -gt 0 ]] && verb="V" #Pass verbose mode + [[ $verbose_flag -ne 3 ]] && verb="-V $verbose_flag" #Pass verbose mode [[ $build_flag -gt 0 ]] && buildm="b" #Pass build op mode [[ $base_mode_flag -gt 0 ]] && basem="B" #We make sure to pass on eventual base mode to the subcalls [[ $git_mode_flag -gt 0 ]] && gitm="g" #We make sure to pass on eventual git mode to the subcalls [[ $quiet_flag -gt 0 ]] && quietm="q" #We make sure to pass on eventual quiet mode to the subcalls #First pass sets the verbose flag but redirects stderr to /dev/null - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[VERB] Running \"$(dirname "$(basename "$prog_name")") -Y $amboso_start_time -M $makefile_version -S $source_name -E $exec_entrypoint -D $scripts_dir -b$verb$gitm$basem$quietm$silentm$packm$ignore_gitcheck$showtimem $init_vers\" ( $(($i+1)) / $tot_vers )\033[0m\n" >&2 - "$prog_name" -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -E "$exec_entrypoint" -D "$scripts_dir" -b"$verb""$gitm""$basem""$quietm""$silentm""$packm""$ignore_gitcheck""$showtimem" "$init_vers" 2>/dev/null + [[ $verbose_flag -gt 3 ]] && log_cl "[VERB] Running \"$(dirname "$(basename "$prog_name")") -Y $amboso_start_time -M $makefile_version -S $source_name -E $exec_entrypoint -D $scripts_dir $verb $configm -b$gitm$basem$quietm$silentm$packm$ignore_gitcheck$showtimem$plainm$loggedm$norebuildm$forcebuildm $init_vers\" ( $(($i+1)) / $tot_vers )" info >&2 + "$prog_name" -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -E "$exec_entrypoint" -D "$scripts_dir" $verb $configm -b"$gitm""$basem""$quietm""$silentm""$packm""$ignore_gitcheck""$showtimem""$plainm""$loggedm""$norebuildm""$forcebuildm" "$init_vers" 2>/dev/null if [[ $? -eq 0 ]] ; then { - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[INIT] $init_vers binary ready.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[INIT] $init_vers binary ready." info >&2 count_bins=$(($count_bins +1)) } else { verbose_hint="" [[ $verbose_flag -lt 1 ]] && verbose_hint="Run with -V to see more info." - printf "\n\033[1;31m[INIT] Failed build for $init_vers binary. $verbose_hint\e[0m\n\n" + log_cl "[INIT] Failed build for $init_vers binary. $verbose_hint\n" error #try building again to get more output, since we discarded stderr before # #we could just pass -v to the first call if we have it on - if [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]]; then { - printf "[INIT] Checking errors, running \033[1;33m$(basename "$prog_name") -bV$packm$ignore_gitcheck $init_vers\e[0m.\n" >&2 - ("$prog_name" -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -D "$scripts_dir" -E "$exec_entrypoint" -V 2 -b"$gitm""$basem""$packm""$ignore_gitcheck""$showtimem" "$init_vers") >&2 + if [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]]; then { + log_cl "[INIT] Checking errors, running $(basename "$prog_name") -bV$packm$ignore_gitcheck $init_vers" info >&2 + ("$prog_name" -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -D "$scripts_dir" -E "$exec_entrypoint" -V 2 -b"$gitm""$basem""$packm""$ignore_gitcheck""$showtimem""$plainm""$loggedm""$norebuildm""$forcebuildm" "$init_vers") >&2 } fi } @@ -1700,26 +1915,27 @@ amboso_parse_args() { display_zero="" } fi - printf "\033[0;34m[INIT] Took $display_zero$runtime_init seconds, ( $count_bins / $tot_vers ) binaries ready.\e[0m\n" + log_cl "[INIT] Took $display_zero$runtime_init seconds, ( $count_bins / $tot_vers ) binaries ready." info #We don't quit after the full build. #exit 0 } fi - if [[ $init_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] ; then { - printf "\033[0;35m[TEST] [-i]\e[0m Will record all tests.\n" >&2 + if [[ $init_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] ; then { + log_cl "[TEST] [-i] Will record all tests." info >&2 + log_cl "DEPRECATED" warn >&2 } fi - if [[ $purge_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] ; then { + if [[ $purge_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] ; then { : #echo -e "\033[0;35m[TEST] [-p]\e[0m Will clean all tests." >&2 } fi - if [[ $build_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] ; then { - printf "\033[0;35m[TEST] [-b]\e[0m Will record test query.\n" >&2 + if [[ $build_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] ; then { + log_cl "[TEST] [-b] Will record test query." info >&2 } fi - if [[ $delete_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] ; then { + if [[ $delete_flag -gt 0 && $test_mode_flag -gt 0 ]] && [[ $verbose_flag -gt 3 || $quiet_flag -eq 0 ]] ; then { : #echo -e "\033[0;35m[TEST] [-d]\e[0m Will clean test query." >&2 } @@ -1732,27 +1948,31 @@ amboso_parse_args() { app "$(echo_node doing_test_macro end_node)" end_digraph if [[ $quiet_flag -eq 0 ]] ; then { - printf "\033[1;33m[DEBUG] -t assert: shortcut to run \"$prog_name\" with -T\n" - printf "\033[1;33m[DEBUG] will pass: ( -qVbw ) to subcall, if asserted.\n\n" + log_cl "-t assert: shortcut to run \"$prog_name\" with -T" debug + log_cl "will pass: ( -qVbw ) to subcall, if asserted.\n" debug } fi quietm="" verbm="" buildm="" showtimem="" + plainm="" + loggedm="" + [[ $do_filelog_flag -gt 0 ]] && loggedm="J" + [[ $allow_color_flag -le 0 ]] && plainm="P" [[ $show_time_flag -gt 0 ]] && showtimem="w" [[ $quiet_flag -gt 0 ]] && quietm="q" - [[ $verbose_flag -gt 0 ]] && verbm="V" + [[ $verbose_flag -ne 3 ]] && verbm="-V $verbose_flag" [[ $build_flag -gt 0 ]] && buildm="b" - [[ $init_flag -gt 0 ]] && buildm="b" && printf "\033[1;31m[DEBUG] Recording all tests with -ti is deprecated.\n\n Feature will be dropped in next major update.\n\n" + [[ $init_flag -gt 0 ]] && log_cl "Recording all tests with -ti is deprecated." error && exit 2 tot_successes=0 tot_failures=0 start_t_tests=$(date +%s.%N) for i in $(seq 0 $(($tot_tests-1))); do { - [[ $quiet_flag -eq 0 ]] && printf "\033[1;35m[TEST-MACRO] Running: \"$prog_name -Y $amboso_start_time -T$quietm$verbm$buildm$showtimem -K $kazoj_dir -D $milestones_dir ${supported_tests[$i]}\"\e[0m\n" >&2 + [[ $quiet_flag -eq 0 ]] && log_cl "[TEST-MACRO] Running: \"$(basename "$prog_name") -Y $amboso_start_time $verbm -T$quietm$buildm$showtimem$plainm$loggedm -K $kazoj_dir -D $scripts_dir ${supported_tests[$i]}\"" info >&2 start_t_curr_test=$(date +%s.%N) - "$prog_name" -Y "$amboso_start_time" -T"$quietm$verbm$buildm""$showtimem" -K "$kazoj_dir" -D "$milestones_dir" "${supported_tests[$i]}" + "$prog_name" -Y "$amboso_start_time" $verbm -T"$quietm$buildm""$showtimem""$plainm""$loggedm" -K "$kazoj_dir" -D "$scripts_dir" "${supported_tests[$i]}" retcod="$?" if [[ $retcod -eq 0 ]] ; then { tot_successes=$(($tot_successes+1)) @@ -1761,7 +1981,7 @@ amboso_parse_args() { } fi if [[ $retcod -eq 69 ]] ; then { - printf "\033[1;31m[PANIC] A test call returned 69 while in macro mode. Doing the same.\e[0m\n\n" + log_cl "[PANIC] A test call returned 69 while in macro mode. Doing the same.\n" error echo_timer "$amboso_start_time" "Test returned 69" "1" exit 69 } @@ -1775,7 +1995,7 @@ amboso_parse_args() { display_zero="" } fi - [[ $quiet_flag -eq 0 ]] && printf "\033[0;34m[TEST] ($(($i+1))/$tot_tests) took $display_zero$runtime_curr_test seconds.\e[0m\n" + [[ $quiet_flag -eq 0 ]] && log_cl "[TEST] ($(($i+1))/$tot_tests) took $display_zero$runtime_curr_test seconds." info } done end_t_tests=$(date +%s.%N) @@ -1789,11 +2009,11 @@ amboso_parse_args() { fi #echo -e "\033[0;34m[TEST] Full testing took $display_zero$runtime_tests seconds ( $tot_tests done).\e[0m\n" echo_timer "$amboso_start_time" "Test macro" "6" - printf "\033[1;35m[TEST] Successes: {\033[0m\033[1;32m%s\033[1;35m}\033[0m\n" "$tot_successes" - printf "\033[1;35m[TEST] Failures: {\033[0m\033[1;31m%s\033[1;35m}\033[0m\n" "$tot_failures" + log_cl "[TEST] Successes: {$tot_successes}" info + log_cl "[TEST] Failures: {$tot_failures}" info exit $tot_failures } elif [[ $small_test_mode_flag -gt 0 && $test_mode_flag -gt 0 ]] ; then { - printf "\033[1;31m[PANIC] [-t] used with [-T].\n\n -t is a shortcut to run as -T on all tests found.\e[0m\n\n" + log_cl "[PANIC] [-t] used with [-T].\n\n -t is a shortcut to run as -T on all tests found.\n" info echo_timer "$amboso_start_time" "Wrong test flag usage" "1" exit 1 } @@ -1825,14 +2045,15 @@ amboso_parse_args() { } fi - if [[ $quiet_flag -eq 0 && $verbose_flag -gt 1 ]]; then { #WIP - printf "\033[1;35m[VERB] SYNCPOINT: shifted args, query was: ( $query ).\e[0m\n" >&2 + if [[ $quiet_flag -eq 0 && $verbose_flag -ge 4 ]]; then { #WIP + log_cl "[VERB] SYNCPOINT: shifted args, query was: ( $query )." debug >&2 } fi tot_left_args=$(( $# )) if [[ $tot_left_args -gt 1 ]]; then { - printf "\n\033[1;31m[ERROR] Unknown argument: \"$2\" (ignoring other $(($tot_left_args-1)) args).\e[0m\n\n" + log_cl "\n Unknown argument: \"$2\" (ignoring other $(($tot_left_args-1)) args).\n" error + log_cl "Current \$@: \"$@\"" error amboso_usage echo_timer "$amboso_start_time" "Unknown arg [$2]" "1" exit 1 @@ -1842,38 +2063,40 @@ amboso_parse_args() { #If we don't have init or purge flag, we bail on a missing version argument if [[ $tot_left_args -lt 1 && $purge_flag -eq 0 && $init_flag -eq 0 && $test_mode_flag -eq 0 ]]; then { app "$(echo_node silence_check missing_query)" + try_doing_make + make_res="$?" app "$(echo_node missing_query end_node)" end_digraph - printf "\033[1;31m[ERROR] Missing query.\e[0m\n\n" - printf "\033[1;33m Run with -h for help.\e[0m\n\n" + #printf "\033[1;31m[ERROR] Missing query.\e[0m\n\n" + #printf "\033[1;33m Run with -h for help.\e[0m\n\n" echo_timer "$amboso_start_time" "Missing query" "1" - return 1 + return "$make_res" } elif [[ $tot_left_args -lt 1 && $test_mode_flag -gt 0 ]] ; then { app "$(echo_node silence_check missing_test_query)" app "$(echo_node missing_test_query end_node)" end_digraph #If in test mode, we still whine about a target test - printf "\033[1;31m[ERROR] Missing test query.\e[0m\n\n" - printf "\033[1;33m Run with -h for help.\e[0m\n\n" - printf "can we do init/purge?\n" #TODO wth does this mean + log_cl "Missing test query.\n" error + log_cl " Run with -h for help.\n" error + #printf "can we do init/purge?\n" #TODO wth does this mean } fi #Check if we are doing a test if [[ $test_mode_flag -gt 0 ]]; then { app "$(echo_node recursion_lt_3 doing_test)" - if [[ $quiet_flag -eq 0 && $verbose_flag -gt 1 ]]; then { #WIP - printf "\033[1;35m[VERB] Test mode (-T was on).\e[0m\n" >&2 - [[ $small_test_mode_flag -gt 0 ]] && printf "\033[1;35m[VERB] (-t was on).\e[0m\n" >&2 + if [[ $quiet_flag -eq 0 && $verbose_flag -ge 4 ]]; then { #WIP + log_cl "[VERB] Test mode (-T was on)." info >&2 + [[ $small_test_mode_flag -gt 0 ]] && log_cl "[VERB] (-t was on)." info >&2 echo_tests_info "$kazoj_dir" >&2 } fi test_name="" test_type="" test_path="" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Checking if query $query is a testcase.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Checking if query $query is a testcase." info >&2 for i in $(seq 0 $(($count_tests_names-1))); do { current_item="${read_tests_files[$i]}" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Checking case ($i/$count_tests_names): $current_item\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Checking case ($i/$count_tests_names): $current_item" info >&2 #echo "checking $current_item" if [[ $query = "$current_item" ]]; then { test_type="casetest" @@ -1885,10 +2108,10 @@ amboso_parse_args() { } done if [[ -z $test_name ]] ; then { - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Checking if query $query is a error testcase.\e[0m\n" >&2 + [[ $verbose_flag -ge 4 ]] && log_cl "[TEST] Checking if query $query is a error testcase." info >&2 for i in $(seq 0 $(($count_errortests_names-1))); do { current_item="${read_errortests_files[$i]}" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Checking error case ($i/$count_errortests_names): $current_item\e[0m\n" >&2 + [[ $verbose_flag -ge 4 ]] && log_cl "[TEST] Checking error case ($i/$count_errortests_names): $current_item" info >&2 #echo "checking $current_item" if [[ $query = "$current_item" ]] ; then { test_type="errortest" @@ -1903,7 +2126,7 @@ amboso_parse_args() { fi if [[ $quiet_flag -eq 0 ]]; then { #WIP - printf "\033[0;34m[TEST] Expected:\n\n type: $test_type\n\n name: $test_name\n path: $test_path\n\e[0m\n" >&2 + log_cl "[TEST] Expected:\n\n type: $test_type\n\n name: $test_name\n path: $test_path\n" info >&2 } fi @@ -1913,41 +2136,41 @@ amboso_parse_args() { flagbuild="" [[ $build_flag -gt 0 ]] && flagbuild="b" [[ $init_flag -gt 0 ]] && flaginit="t" - printf "\033[0;35m[VERB] Test path was empty but we have [-$flagbuild$flaginit].\e[0m\n" >&2 + log_cl "[VERB] Test path was empty but we have [-$flagbuild$flaginit]." debug >&2 } fi if [[ -z $test_path && -z $query ]] ; then { - [[ $quiet_flag -eq 0 ]] && printf "\033[0;35m[VERB] testpath was empty, query was empty. Should quit.\e[0m\n" >&2 + [[ $quiet_flag -eq 0 ]] && log_cl "[VERB] testpath was empty, query was empty. Should quit." debug >&2 keep_run_txt="" if [[ $init_flag -gt 0 ]] ; then { keep_run_txt="[INIT]" - printf "\033[1;33m[TEST] ( \"empty\"[$query] ) is not a supported tag. $keep_run_txt.\e[0m\n" >&2 + log_cl "[TEST] ( \"empty\"[$query] ) is not a supported tag. $keep_run_txt." error >&2 echo_timer "$amboso_start_time" "Empty test query" "1" exit 1 } fi - printf "\033[0;35m[VERB] UNREACHABLE.\e[0m\n" + printf "${FUNCNAME[0]}(): UNREACHABLE.\n" exit 1 } elif [[ -z $test_path && ! -z $query ]] ; then { - [[ $quiet_flag -eq 0 ]] && printf "\033[0;35m[VERB] testpath was empty, query was not empty: ( $query ).\e[0m\n" >&2 + [[ $quiet_flag -eq 0 ]] && log_cl "[VERB] testpath was empty, query was not empty: ( $query )." info >&2 keep_run_txt="" if [[ $init_flag -gt 0 ]] ; then { keep_run_txt="[INIT]" - printf "\033[1;33m[TEST] ( $query ) is not a supported tag, we quit at this point. $keep_run_txt.\e[0m\n" >&2 + log_cl "[TEST] ( $query ) is not a supported tag, we quit at this point. $keep_run_txt." error >&2 echo_timer "$amboso_start_time" "Unsupported test query [$query]" "3" exit 0 } fi - [[ $build_flag -gt 0 ]] && keep_run_txt="[BUILD]" && printf "\033[1;33m[TEST] ( $query ) is not a supported tag, but we continue to $keep_run_txt.\e[0m\n" >&2 + [[ $build_flag -gt 0 ]] && keep_run_txt="[BUILD]" && log_cl "[TEST] ( $query ) is not a supported tag, but we continue to $keep_run_txt." debug >&2 } else { - [[ $verbose_flag -gt 0 || $quiet_flag -eq 0 ]] && printf "\033[0;33m[TEST] expected:\n $test_type\n\n name: $test_name\n path: $test_path\e[0m\n"# >&2 - printf "\033[0;32m[TEST] target: ( $test_path ).\e[0m\n\n" + [[ $verbose_flag -ge 4 || $quiet_flag -eq 0 ]] && log_cl "[TEST] expected:\n $test_type\n\n name: $test_name\n path: $test_path" debug # >&2 + log_cl "[TEST] target: ( $test_path ).\n" info } fi } elif [[ -z $test_path && -z $query ]] ; then { #Panic - printf "\033[1;31m[ERROR] ( $test_name : at $test_path ) is not a supported test.\e[0m\n\n" - printf "\033[1;33m Run with -h for help.\e[0m\n\n" + log_cl "( $test_name : at $test_path ) is not a supported test.\n" error + log_cl " Run with -h for help.\n" error echo_timer "$amboso_start_time" "Unsupported test name [$test_name] at [$test_path]" "1" exit 1 } @@ -1956,7 +2179,7 @@ amboso_parse_args() { relative_testpath="$test_path" if [[ $build_flag -gt 0 ]] ; then { - printf "\033[0;34m[TEST] \"-b\" is set, Recording: ( $relative_testpath ).\e[0m\n" >&2 + log_cl "[TEST] \"-b\" is set, Recording: ( $relative_testpath )." debug >&2 #record_test "$relative_testpath" } elif [[ $delete_flag -gt 0 ]] ; then { : @@ -1964,22 +2187,27 @@ amboso_parse_args() { #delete_test "$relative_testpath" } elif [[ $init_flag -gt 0 ]] ; then { #echo "UNREACHABLE." && exit 1 - printf "\033[0;34m[TEST] \"-i\" is set, Recording ALL: ( $relative_testpath ).\e[0m\n" - printf "\033[1;33m[DEBUG] ( $tot_tests ) total tests ready.\e[0m\n" >&2 + log_cl "[TEST] \"-i\" is set, Recording ALL: ( $relative_testpath )." debug + log_cl "( $tot_tests ) total tests ready." debug >&2 for i in $(seq 0 $(($tot_tests-1))); do { TEST="${supported_tests[$i]}" verb="" quietm="" showtimem="" + plainm="" + loggedm="" + [[ $do_filelog_flag -gt 0 ]] && loggedm="J" + [[ $allow_color_flag -le 0 ]] && plainm="P" [[ $show_time_flag -gt 0 ]] && showtimem="w" [[ $quiet_flag -gt 0 ]] && quietm="q" #We make sure to pass on eventual quiet flag mode to the subcalls - [[ $verbose_flag -gt 0 ]] && verb="V" && printf "\n[TEST] Recording ALL: ( $(($i+1)) / $tot_tests ) ( $TEST )\n" >&2 - printf "\033[1;35m[TEST] Running:\e[0m \033[1;34m\"$prog_name -K $kazoj_dir -D $scripts_dir -bT$quietm$verb$showtimem $TEST 2>/dev/null \"\e[0m\n" + [[ $verbose_flag -ne 3 ]] && verb="-V $verbose_flag" + [[ $verbose_flag -gt 3 ]] && printf "\n[TEST] Recording ALL: ( $(($i+1)) / $tot_tests ) ( $TEST )\n" >&2 + log_cl "[TEST] Running: \"$prog_name -K $kazoj_dir -D $scripts_dir $verb -bT$quietm$showtimem$plainm$loggedm $TEST 2>/dev/null \"\e[0m\n" debug start_t=$(date +%s.%N) - ( "$prog_name" -Y "$amboso_start_time" -K "$kazoj_dir" -D "$scripts_dir" -b"$quietm""$verb""$showtimem"T "$TEST" 2>/dev/null ; exit "$?") + ( "$prog_name" -Y "$amboso_start_time" -K "$kazoj_dir" -D "$scripts_dir" $verb -b"$quietm""$showtimem""$plainm""$loggedm"T "$TEST" 2>/dev/null ; exit "$?") record_res="$?" if [[ $record_res -eq 69 ]]; then { - printf "\033[1;31m[PANIC] Unsupported: a test call returned 69. Will do the same.\e[0m\n\n" && + log_cl "[PANIC] Unsupported: a test call returned 69. Will do the same.\n" error && echo_timer "$amboso_start_time" "Record Test call returned 69" "1" exit 69 } @@ -1998,23 +2226,23 @@ amboso_parse_args() { fi if [[ -z $relative_testpath && $init_flag -eq 0 ]] ; then { #Exit 0 as intended behaviour FIXME - printf "\033[1;31m[TEST] Can't proceed further with no valid target path, query was ( $query ).\e[0m\n" - printf "\033[1;31m[TEST] Supported tests:\e[0m\n" + log_cl "[TEST] Can't proceed further with no valid target path, query was ( $query )." warn + log_cl "[TEST] Supported tests:\n" info echo_tests_info "$kazoj_dir" - printf "\033[1;31m[TEST] Quitting.\e[0m\n" + log_cl "[TEST] Quitting." error echo_timer "$amboso_start_time" "Invalid target path [$relative_testpath]" "1" exit 1 } fi if [[ -z $relative_testpath && $init_flag -eq 1 && ! -z $query ]] ; then { #Exit 0 as intended behaviour FIXME - printf "\033[1;31m[ERROR] Can't proceed even with -i flag, with no testpath. ( p: $relative_testpath ) can't be be ( q: $query ).\e[0m\n" + log_cl "Can't proceed even with -i flag, with no testpath. ( p: $relative_testpath ) can't be be ( q: $query )." error echo_timer "$amboso_start_time" "Invalid target path (-i) [$relative_testpath]" "1" exit 0 } fi if [[ -z $relative_testpath && $init_flag -eq 1 && -z $query ]] ; then { - printf "\033[1;31m[ERROR] Can't proceed with no query. ( q: $query, p: $relative_testpath ).\e[0m\n" + log_cl "Can't proceed with no query. ( q: $query, p: $relative_testpath )." error echo_timer "$amboso_start_time" "Empty test query [$query]" "1" exit 1 } @@ -2023,23 +2251,23 @@ amboso_parse_args() { run_tmp_escout="$(mktemp)" run_tmp_err="$(mktemp)" run_tmp_escerr="$(mktemp)" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[TEST] Created tempfiles.\e[0m\n" >&2 - printf "\033[0;36m[TEST] Running:\e[0m \033[1;35m\"$relative_testpath\"\e[0m\n" + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Created tempfiles." debug >&2 + log_cl "[TEST] Running: \"$relative_testpath\"" debug run_test "$relative_testpath" >>"$run_tmp_out" 2>>"$run_tmp_err" ran_res="$?" if [[ $ran_res -eq 69 ]] ; then { - printf "\033[1;31m[WARN] Test call returned 69, we clean tmpfiles and follow suit.\e[0m\n" + log_cl "Test call returned 69, we clean tmpfiles and follow suit." warn #Delete tmpfiles - rm -f "$run_tmp_out" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_out). Why?\e[0m\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_out\".\e[0m\n" >&2 - rm -f "$run_tmp_err" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_err). Why?\e[0m\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_err\".\e[0m\n" >&2 - rm -f "$run_tmp_escout" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_escout). Why?\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_escout\".\e[0m\n" >&2 - rm -f "$run_tmp_escerr" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_escerr). Why?\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_escerr\".\e[0m\n" >&2 - printf "\033[1;31m[PANIC] Quitting with 69.\e[0m\n" + rm -f "$run_tmp_out" || log_cl "Failed removing tmpfile ($run_tmp_out). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_out\"." debug >&2 + rm -f "$run_tmp_err" || log_cl "Failed removing tmpfile ($run_tmp_err). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_err\"." debug >&2 + rm -f "$run_tmp_escout" || log_cl "Failed removing tmpfile ($run_tmp_escout). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_escout\"." debug >&2 + rm -f "$run_tmp_escerr" || log_cl "Failed removing tmpfile ($run_tmp_escerr). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_escerr\".\n" debug >&2 + log_cl "[PANIC] Quitting with 69." error echo_timer "$amboso_start_time" "Test run ended with 69" "1" exit 69 } @@ -2051,13 +2279,13 @@ amboso_parse_args() { cp "$run_tmp_escout" "$relative_testpath.stdout" || printf "Failed replacing stdout with new file.\n" cp "$run_tmp_escerr" "$relative_testpath.stderr" || printf "Failed replacing stderr with new file.\n" } else { - [[ $quiet_flag -eq 0 || $verbose_flag -gt 0 ]] && printf "\033[1;33m[TEST] Won't record, no [-b].\e[0m\n\n" + [[ $quiet_flag -eq 0 || $verbose_flag -gt 3 ]] && log_cl "[TEST] Won't record, no [-b].\n" info } fi - rm -f "$run_tmp_out" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_out). Why?\e[0m\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_out\".\e[0m\n" >&2 - rm -f "$run_tmp_err" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_err). Why?\e[0m\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_err\".\e[0m\n" >&2 + rm -f "$run_tmp_out" || log_cl "Failed removing tmpfile ($run_tmp_out). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_out\"." debug >&2 + rm -f "$run_tmp_err" || log_cl "Failed removing tmpfile ($run_tmp_err). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_err\"." debug >&2 #Testing diff for escaped stdout ( diff "$run_tmp_escout" "$relative_testpath".stdout ) 2>/dev/null 1>&2 diff_res="$?" @@ -2066,35 +2294,35 @@ amboso_parse_args() { out_res="pass" if [[ ! -z "$run_tmp_escout" ]] ; then { #FIXME: SC2157 && ! -z "$relative_testpath".stdout ]]; then { #This one doesn't go on stderr since we still want it in recursive calls: - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Pass, both outputs are not empty.\e[0m\n" + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Pass, both outputs are not empty." debug } elif [[ -z "$run_tmp_escout" ]]; then { - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Pass, current stdout is empty. Is that expected?\e[0m\n">&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Pass, current stdout is empty. Is that expected?" info >&2 } #FIXME: SC2157 elif [[ -z "$relative_testpath.stdout" ]]; then { #[[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Pass, registered stdout is empty. Is that expected?\e[0m\n" >&2 #} fi - if [[ $verbose_flag -gt 0 && $quiet_flag -eq 0 ]]; then { - printf "\n\033[0;32m[TEST] (stdout) Expected:\e[0m\n" + if [[ $verbose_flag -gt 3 && $quiet_flag -eq 0 ]]; then { + log_cl "[TEST] (stdout) Expected:" info cat "$relative_testpath.stdout" - printf "\n\033[0;32m[TEST] (stdout) Found:\e[0m\n" + log_cl "[TEST] (stdout) Found:" info cat "$run_tmp_escout" } fi } else { out_res="fail" if [[ $quiet_flag -eq 0 ]]; then { - printf "\n\033[1;31m[TEST] (stdout) Expected:\e[0m\n" + log_cl "[TEST] (stdout) Expected:" info cat "$relative_testpath.stdout" - printf "\n\033[1;31m[TEST] (stdout) Found:\e[0m\n" + log_cl "[TEST] (stdout) Found:" error cat "$run_tmp_escout" } fi - printf "\033[1;31m[TEST] Failed: stdout changed.\e[0m\n" + log_cl "[TEST] Failed: stdout changed." error #cat "$run_tmp_escout" } fi - rm -f "$run_tmp_escout" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_escout). Why?\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_escout\".\e[0m\n" >&2 + rm -f "$run_tmp_escout" || log_cl "Failed removing tmpfile ($run_tmp_escout). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_escout\"." debug >&2 #Testing diff for escaped stderr ( diff "$run_tmp_escerr" "$relative_testpath".stderr ) 2>/dev/null 1>&2 diff_res="$?" @@ -2102,17 +2330,17 @@ amboso_parse_args() { err_res="pass" if [[ ! -z "$run_tmp_escerr" ]]; then { #FIXME SC2157 && ! -z "$relative_testpath.stderr" ]]; then { #This one doesn't go on stderr since we still want it in recursive calls: - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Pass, both stderrs are not empty.\e[0m\n" + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Pass, both stderrs are not empty." debug } elif [[ -z "$run_tmp_escerr" ]]; then { - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Pass, current run stderr is empty. Is that expected?\e[0m\n">&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Pass, current run stderr is empty. Is that expected?" info >&2 } #FIXME SC2157 elif [[ -z "$relative_testpath.stderr" ]]; then { # [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[TEST] Pass, registered stderr is empty. Is that expected?\e[0m\n" >&2 #} fi - if [[ $verbose_flag -gt 0 && $quiet_flag -eq 0 ]]; then { - printf "\n\033[0;32m[TEST] (stderr) Expected:\e[0m\n" + if [[ $verbose_flag -gt 3 && $quiet_flag -eq 0 ]]; then { + log_cl "[TEST] (stderr) Expected:" info cat "$relative_testpath.stderr" - printf "\n\033[0;32m[TEST] (stderr) Found:\e[0m\n" + log_cl "[TEST] (stderr) Found:" info cat "$run_tmp_escerr" } fi @@ -2120,27 +2348,27 @@ amboso_parse_args() { } else { err_res="fail" if [[ $quiet_flag -eq 0 ]]; then { - printf "\n\033[1;31m[TEST] (stderr) Expected:\e[0m\n" + log_cl "[TEST] (stderr) Expected:" info cat "$relative_testpath.stderr" - printf "\n\033[1;31m[TEST] (stderr) Found:\e[0m\n" + log_cl "[TEST] (stderr) Found:" error cat "$run_tmp_escerr" } fi - printf "\033[1;31m[TEST] Failed: stderr changed.\e[0m\n" + log_cl "[TEST] Failed: stderr changed." error #cat "$run_tmp_escerr" } fi - rm -f "$run_tmp_escerr" || printf "\033[1;31m[ERROR] Failed removing tmpfile ($run_tmp_escerr). Why?\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[TEST] Removed tempfile \"$run_tmp_escerr\".\e[0m\n" >&2 + rm -f "$run_tmp_escerr" || log_cl "Failed removing tmpfile ($run_tmp_escerr). Why?\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[TEST] Removed tempfile \"$run_tmp_escerr\"." debug >&2 if [[ $build_flag -gt 0 ]] ; then { #We simulate success since we're recording - printf "\033[1;33m[TEST] Phony pass (recording).\e[0m\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m (out: $out_res)\e[0m\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m (err: $err_res)\e[0m\n" + log_cl "[TEST] Phony pass (recording)." debug + [[ $verbose_flag -gt 3 ]] && log_cl "(out: $out_res)" debug + [[ $verbose_flag -gt 3 ]] && log_cl "(err: $err_res)" debug echo_timer "$amboso_start_time" "Phony test pass" "3" exit 0 #We return earlier } elif [[ $out_res = "pass" && $err_res = "pass" ]]; then { - printf "\033[1;32m[TEST] Passed.\e[0m\n" + log_cl "[TEST] Passed." info echo_timer "$amboso_start_time" "Test pass" "2" exit 0 #We return earlier } elif [[ $out_res = "fail" ]] ; then { @@ -2148,7 +2376,7 @@ amboso_parse_args() { } elif [[ $err_res = "fail" ]] ; then { : #echo "failed" #We echoed before } else { - printf "\033[1;31m[ERROR] Unexpected values (o:$out_res/e:$err_res) should be either pass or fail.\e[0m. How?\n" + log_cl "Unexpected values (o:$out_res/e:$err_res) should be either pass or fail. How?" error } fi echo_timer "$amboso_start_time" "Test fail" "1" @@ -2169,15 +2397,15 @@ amboso_parse_args() { app "$(echo_node silence_check query_invalid)" app "$(echo_node query_invalid end_node)" end_digraph - printf "\033[1;31m[ERROR] ( $query ) is not a supported tag.\e[0m\n\n" - printf "\033[1;33m Run with -h for help.\e[0m\n\n" + log_cl "( $query ) is not a supported tag.\n" error + log_cl " Run with -h for help.\n" error echo_timer "$amboso_start_time" "Invalid query [$query]" "1" exit 1 } elif [[ ! -z $query && $test_mode_flag -gt 0 ]] ; then { #If we're in test mode, gently tell the user that the version is not supported keep_run_txt="" [[ $init_flag -gt 0 ]] && keep_run_txt="${mode_txt}[INIT]" [[ $purge_flag -gt 0 ]] && keep_run_txt="${mode_txt}[PURGE]" - printf "\n\033[1;33m[DEBUG] ( $query ) is not a supported test. $keep_run_txt.\e[0m\n" >&2 + log_cl "( $query ) is not a supported test. $keep_run_txt." debug >&2 echo_timer "$amboso_start_time" "Invalid test query [$query]" "1" exit 1; } @@ -2187,7 +2415,7 @@ amboso_parse_args() { #We now should have a valid $version value, outside of purge or init mode if [[ $gen_C_headers_set -gt 0 && $gen_C_headers_flag -gt 0 ]]; then { - printf "\033[1;36m[AMBOSO] Generate C header for [$version].\e[0m\n" >&2 + log_cl "[AMBOSO] Generate C header for [$version]." info >&2 gen_C_headers "$gen_C_headers_destdir" "$version" "$exec_entrypoint" } fi @@ -2203,18 +2431,23 @@ amboso_parse_args() { fi #If we can't find the file we may try to build it - if [[ ! -f "$script_path/$exec_entrypoint" && ! -z $version ]] ; then { - if [[ $init_flag -eq 0 ]] ; then { + if [[ ! -z "$version" && ( ( ! -f "$script_path/$exec_entrypoint" ) || "$force_build_flag" -gt 0 ) ]] ; then { + if [[ "$init_flag" -eq 0 ]] ; then { app "$(echo_node silence_check query_success_not_ready)" } fi - printf "\n\033[1;33m[QUERY] ( $version ) binary not found in ( $script_path ).\e[0m\n" #>&2 - if [[ $verbose_flag -gt 0 ]] ; then { + if [[ "$force_build_flag" -le 0 ]] ; then { + log_cl "[QUERY] ( $version ) binary not found in ( $script_path )." warn #>&2 + } else { + log_cl "[QUERY] Forcing build for ( $version ) binary." debug #>&2 + } + fi + if [[ $verbose_flag -gt 3 ]] ; then { echo_tag_info "$version" } fi if [[ ! $build_flag -gt 0 ]] ; then { #We exit here if we don't want to try building and we're not going to purge - printf "\033[0;33m[DEBUG] To try building, run with -b flag\e[0m\n\n" >&2 + log_cl "To try building, run with -b flag\n" debug >&2 if [[ ! $purge_flag -gt 0 ]] ; then { app "$(echo_node query_success_not_ready end_node)" end_digraph @@ -2224,7 +2457,7 @@ amboso_parse_args() { fi } else { if [[ ! -d "$script_path" ]] ; then - printf "\033[1;31m[ERROR] '$script_path' is not a valid directory.\n Check your supported versions for details on ( $version ).\e[0m\n\n" >&2 + log_cl "'$script_path' is not a valid directory.\n Check your supported versions for details on ( $version ).\n" error >&2 app "$(echo_node query_success_not_ready end_node)" end_digraph echo_timer "$amboso_start_time" "Invalid path [$script_path]" "1" @@ -2237,10 +2470,10 @@ amboso_parse_args() { tool_txt="make" if [[ $can_automake -gt 0 ]] ; then { #We support automake by doing autoreconf and ./configure before running make. tool_txt="automake" - printf "\033[0;33m[MODE] target ( $version ) >= ( $use_autoconf_version ), can autoconf.\e[0m\n" >&2 + log_cl "[MODE] target ( $version ) >= ( $use_autoconf_version ), can autoconf." debug >&2 autoreconf if [[ $? -ne 0 ]] ; then { - printf "\033[1;33m[WARN]\033[0m autoreconf failed. Doing {\033[1;34mautomake --add-missing\033[0m}\n" >&2 + log_cl "autoreconf failed. Doing \"automake --add-missing ; autoreconf\"" warn >&2 automake --add-missing autoreconf } @@ -2248,101 +2481,119 @@ amboso_parse_args() { configure_arg="" if [[ "$pass_autoconf_arg_flag" -eq 1 ]] ; then { configure_arg="$(cat "$autoconf_arg_file")" - printf "\033[1;34m[CONF] Running \"\033[1;36m%s\033[1;34m\"\033[0m\n" "./configure $configure_arg" + log_cl "[CONF] Running \"./configure $configure_arg\"" debug } fi ./configure "$configure_arg" configure_res="$?" if [[ "$configure_res" -ne 0 ]]; then { - printf "\033[1;33m[WARN] ./configure returned {\033[1;31m%s\033[1;33m}\033[0m\n" "$configure_res" + log_cl "./configure returned {$configure_res}" warn } fi - printf "\033[0;32m[INFO] Done 'autoreconf' and './configure'.\e[0m\n" >&2 + log_cl "Done 'autoreconf' and './configure'." info >&2 } fi - printf "\033[0;33m[MODE] target ( $version ) >= ( $makefile_version ), has Makefile.\e[0m\n" >&2 - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[BUILD] Building ( $version ), using make.\e[0m\n" >&2 + log_cl "[MODE] target ( $version ) >= ( $makefile_version ), has Makefile." debug >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Building ( $version ), using make." debug >&2 curr_dir=$(realpath .) start_t=$(date +%s.%N) if [[ $git_mode_flag -eq 0 && $base_mode_flag -eq 1 ]] ; then { #Building in base mode, we cd into target directory before make - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[BUILD] Running in base mode, expecting full source in $script_path.\e[0m\n" #>&2 - cd "$script_path" || { printf "\033[1;31m[CRITICAL] cd failed. Quitting.\n"; exit 4 ; }; make >&2 - comp_res=$? + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Running in base mode, expecting full source in $script_path." debug #>&2 + cd "$script_path" || { log_cl "[CRITICAL] cd failed. Quitting." error ; exit 4 ; }; + if [[ "$enable_make_rebuild_flag" -gt 0 ]] ; then { + log_cl "Running \"make rebuild\"" debug + make rebuild >&2 + comp_res=$? + } else { + log_cl "Running \"make\"" debug + make >&2 + comp_res=$? + } + fi } else { #Building in git mode, we checkout the tag and move the binary after the build - [[ $verbose_flag -gt 0 ]] && printf "\033[0;34m[BUILD] Running in git mode, checking out ( $version ).\e[0m\n" #>&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Running in git mode, checking out ( $version )." debug #>&2 git checkout "$version" 2>/dev/null #Repo goes back to tagged state checkout_res=$? if [[ $checkout_res -gt 0 ]] ; then { #Checkout failed, we don't build and we set comp_res - printf "\033[1;31m[ERROR] Checkout of ( $version ) failed, this stego.lock tag does not work for the repo.\e[0m\n" #>&2 + log_cl "Checkout of ( $version ) failed, this stego.lock tag does not work for the repo." error #>&2 comp_res=1 } else { #Checkout successful, we build git submodule update --init --recursive #We set all submodules to commit state - make >&2 #Never try to build if checkout fails - comp_res=$? + #Never try to build if checkout fails + if [[ "$enable_make_rebuild_flag" -gt 0 ]] ; then { + log_cl "Running \"make rebuild\"" debug + make rebuild >&2 + comp_res=$? + } else { + log_cl "Running \"make\"" debug + make >&2 + comp_res=$? + } + fi #Output is expected to be in the main dir: if [[ ! -e ./$exec_entrypoint ]] ; then { - printf "\033[1;31m[ERROR] $exec_entrypoint not found at $(pwd).\e[0m\n" #>&2 + log_cl "$exec_entrypoint not found at $(pwd)." error #>&2 } else { mv "./$exec_entrypoint" "$script_path" #All files generated during the build should be ignored by the repo, to avoid conflict when checking out - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[BUILD] Moved $exec_entrypoint to $script_path.\e[0m\n" #>&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Moved $exec_entrypoint to $script_path." debug #>&2 } fi git switch - #We get back to starting repo state switch_res="$?" if [[ $switch_res -gt 0 ]]; then { - printf "\n\033[1;31m[ERROR] Can't finish checking out ($version).\n You may have a dirty index and may need to run \033[1;35\"git restore .\"\e[0m.\n Abort.\n\n" + log_cl "\nCan't finish checking out ($version).\n You may have a dirty index and may need to run \"git restore .\".\n Quitting.\n" error echo_timer "$amboso_start_time" "Failed checkout" "1" exit 1 } fi git submodule update --init --recursive #We set all submodules to commit state - [[ $quiet_flag -eq 0 ]] && printf "\033[0;32m[BUILD] Switched back to starting commit.\e[0m\n" + [[ $quiet_flag -eq 0 ]] && log_cl "[BUILD] Switched back to starting commit." info } fi } fi end_t=$(date +%s.%N) runtime=$( printf "$end_t - $start_t\n" | bc -l ) - cd "$curr_dir" || { printf "\033[1;31m[CRITICAL] cd failed. Quitting.\n"; exit 4; }; + cd "$curr_dir" || { log_cl "[CRITICAL] cd failed. Quitting." error ; exit 4; }; } else { #Straight gcc mode - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[MODE] target ( $version ) < ( $makefile_version ), single file build with gcc.\e[0m\n" >&2 - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[BUILD] Building ( $version ), using gcc call.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[MODE] target ( $version ) < ( $makefile_version ), single file build with gcc." debug >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Building ( $version ), using gcc call." debug >&2 #echo "" >&2 #new line for error output if [[ -z $source_name ]]; then { - printf "\n\033[1;31m[WTF-ERROR] Missing source file name. ( $version ).\e[0m\n\n" + log_cl "[WTF-ERROR] Missing source file name. ( $version ).\n" error amboso_usage echo_timer "$amboso_start_time" "Missing source name for [$version]" "1" exit 1 } fi - [[ $pack_flag -gt 0 ]] && printf "\n\033[1;33m[PACK] -z is not supported for ($tool_txt). TAG < ($makefile_version).\n\n \033[1;35Current: ($version @ $source_name).\e[0m\n\n" + [[ $pack_flag -gt 0 ]] && log_cl "[PACK] -z is not supported for ($tool_txt). TAG < ($makefile_version).\n\n Current: ($version @ $source_name).\n" error start_t=$(date +%s.%N) if [[ $git_mode_flag -eq 0 ]] ; then { #Building in base mode, we cd into target directory before make - [[ $verbose_flag -gt 0 ]] && printf "\033[0;35m[BUILD] Running in base mode, expecting full source in $script_path.\e[0m\n" #>&2 - gcc "$script_path"/"$source_name" -o "$script_path"/"$exec_entrypoint" -lm 2>&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Running in base mode, expecting full source in $script_path." debug #>&2 + "$CC" "$script_path"/"$source_name" -o "$script_path"/"$exec_entrypoint" -lm "$CFLAGS" 2>&2 comp_res=$? } else { #Building in git mode, we checkout the tag and move the binary after the build - [[ $verbose_flag -gt 0 ]] && printf "\033[0;34m[BUILD] Running in git mode, checking out ( $version ).\e[0m\n" #>&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Running in git mode, checking out ( $version )." debug #>&2 git checkout "$version" 2>/dev/null #Repo goes back to tagged state checkout_res=$? if [[ $checkout_res -gt 0 ]] ; then { #Checkout failed, we set comp_res and don't build - printf "\033[1;31m[ERROR] Checkout of ( $version ) failed, stego.lock may be listing a tag name not on the repo.\e[0m\n" + log_cl "Checkout of ( $version ) failed, stego.lock may be listing a tag name not on the repo." error comp_res=1 } else { - git submodule update --init --recursive 2>/dev/null#We set all submodules to commit state - gcc "./$source_name" -o "$script_path"/"$exec_entrypoint" -lm 2>&2 #Never try to build if checkout fails + git submodule update --init --recursive 2>/dev/null #We set all submodules to commit state + "$CC" "./$source_name" -o "$script_path"/"$exec_entrypoint" -lm "$CFLAGS" 2>&2 #Never try to build if checkout fails comp_res=$? #All files generated during the build should be ignored by the repo, to avoid conflict when checking out git switch - 2>/dev/null #We get back to starting repo state switch_res="$?" if [[ $switch_res -gt 0 ]]; then { - printf "\n\033[1;31m[ERROR] Can't finish checking out ($version). Abort.\n" + log_cl "Can't finish checking out ($version). Quitting." error echo_timer "$amboso_start_time" "Failed checkout for [$version]" "1" exit 1 } fi - [[ $verbose_flag -gt 0 ]] && printf "\033[0;32m[BUILD] Switched back to starting commit.\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[BUILD] Switched back to starting commit." debug >&2 } fi } @@ -2353,10 +2604,10 @@ amboso_parse_args() { fi #Check compilation result if [[ $comp_res -eq 0 ]] ; then - printf "\033[1;32m[BUILD] Done Building ( $version ) , took $runtime seconds, using ( $tool_txt ).\e[0m\n" + log_cl "[BUILD] Done Building ( $version ) , took $runtime seconds, using ( $tool_txt )." info app "$(echo_node building build_success)" else - printf "\033[1;31m[ERROR] Build for ( $version ) failed, quitting.\e[0m\n\n" >&2 + log_cl "Build for ( $version ) failed, quitting.\n" error >&2 app "$(echo_node building build_fail)" app "$(echo_node build_fail end_node)" end_digraph @@ -2374,13 +2625,13 @@ amboso_parse_args() { app "$(echo_node doing_init query_success_ready)" } fi - printf "\n\033[1;32m[QUERY] ( $version ) binary is ready at ( $script_path ) .\e[0m\n\n" >&2 - if [[ $verbose_flag -gt 0 ]] ; then { + log_cl "[QUERY] ( $version ) binary is ready at ( $script_path ) .\n" info >&2 + if [[ $verbose_flag -gt 3 ]] ; then { echo_tag_info "$version" } fi if [[ $build_flag -gt 0 ]] ; then { - printf "\033[0;33m[BUILD] Found binary for ( $version ), won't build.\e[0m\n" >&2 + log_cl "[BUILD] Found binary for ( $version ), won't build.\n" info >&2 app "$(echo_node query_success_ready build_success)" } @@ -2388,13 +2639,13 @@ amboso_parse_args() { #Check if we're packing the ready version if [[ $pack_flag -gt 0 ]] ; then { #We just leverage make pack and assume it's ready to roll - printf "\033[0;35m[PACK] Running in base mode, expecting full source in $script_path.\e[0m\n" #>&2 + log_cl "[PACK] Running in base mode, expecting full source in $script_path." warn #>&2 make pack pack_res=$? if [[ $pack_res -gt 0 ]] ; then { #make pack failed - printf "\033[1;31m[PACK] Packing ($version) in base mode, failed.\n Expected source at ($script_path).\e[0m\n" #>&2 + log_cl "[PACK] Packing ($version) in base mode, failed.\n Expected source at ($script_path)." error #>&2 } else { - printf "\033[1;32m[PACK] Packed ($version):\n from ($script_path)\e[0m\n" #>&2 + log_cl "[PACK] Packed ($version):\n from ($script_path)" info #>&2 } fi } @@ -2402,8 +2653,8 @@ amboso_parse_args() { } elif [[ ! -z $query ]] ; then { app "$(echo_node silence_check query_invalid)" - printf "\033[1;31m[QUERY] ( $query ) invalid query, run with -V to see more.\e[0m\n" - if [[ $verbose_flag -gt 0 ]] ; then { + log_cl "[QUERY] ( $query ) invalid query, run with -V to see more." error + if [[ $verbose_flag -gt 3 ]] ; then { echo_tag_info "$version" } fi @@ -2418,15 +2669,15 @@ amboso_parse_args() { app "$(echo_node query_success_ready running)" } fi - printf "\n\033[0;32m[DEBUG] Running script $script_path/$exec_entrypoint\e[0m\n" + log_cl "\n Running script $script_path/$exec_entrypoint" debug #echo -n "." #sleep 1 #echo "" - ( cd "$script_path" || { printf "\033[1;31m[CRITICAL] cd failed. Quitting.\n"; exit 4 ;} ; ./"$exec_entrypoint" ) + ( cd "$script_path" || { log_cl "[CRITICAL] cd failed. Quitting." error ; exit 4 ;} ; ./"$exec_entrypoint" ) } elif [[ ! -z $version && $run_flag -eq 0 ]] ; then { - printf "\033[0;33m[DEBUG] Running without -r flag, won't run.\e[0m\n" >&2 + log_cl "Running without -r flag, won't run." debug >&2 } elif [[ -z $version && $run_flag -gt 0 ]] ; then { - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[DEBUG] Running with -r but requested an empty tag ( $version )!\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "Running with -r but requested an empty tag ( $version )!" warn >&2 } fi @@ -2448,16 +2699,17 @@ amboso_parse_args() { curr_dir=$(realpath .) delete_path="$scripts_dir""v""$version" if [[ ! -d $delete_path ]] ; then { - printf "\033[1;31m[ERROR] '$delete_path' is not a valid directory.\n Check your supported versions for details on ( $version ).\e[0m\n\n" #>&2 + log_cl "'$delete_path' is not a valid directory.\n Check your supported versions for details on ( $version ).\n" error #>&2 } elif [[ -x $scripts_dir/v$version/$exec_entrypoint ]] ; then { #Executable exists - has_bin=1 && printf "\033[0;33m[DELETE] ( $version ) has an executable.\e[0m\n\n" >&2 - cd "$delete_path" || { printf "\033[1;31m[CRITICAL] cd failed. Quitting.\n"; exit 4 ;}; make clean 2>/dev/null #1>&2 + has_bin=1 && log_cl "[DELETE] ( $version ) has an executable.\n" info >&2 + cd "$delete_path" || { log_cl "[CRITICAL] cd failed. Quitting." error ; exit 4 ;}; + make clean 2>/dev/null #1>&2 clean_res=$? - cd "$curr_dir" || { printf "\033[1;31m[CRITICAL] cd failed. Quitting.\n"; exit 4 ;}; + cd "$curr_dir" || { log_cl "[CRITICAL] cd failed. Quitting." error ; exit 4 ;}; echo_timer "$amboso_start_time" "Did delete, res was [$clean_res]" "3" exit "$clean_res" } else { - [[ $verbose_flag -gt 0 ]] && printf "\033[0;31m[DELETE] ( $version ) does not have an executable at ( $delete_path ).\e[0m\n\n" # >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[DELETE] ( $version ) does not have an executable at ( $delete_path ).\n" debug # >&2 app "$(echo_node deleting no_target_error)" app "$(echo_node no_target_error end_node)" end_digraph @@ -2469,18 +2721,18 @@ amboso_parse_args() { tool_txt="rm" has_bin=0 if [[ -x $scripts_dir"/v$version"/"$exec_entrypoint" ]] ; then { - has_bin=1 && [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[DELETE] ( $version ) has an executable.\e[0m\n" >&2 + has_bin=1 && [[ $verbose_flag -gt 3 ]] && log_cl "[DELETE] ( $version ) has an executable." debug >&2 } fi rm "$(realpath "$scripts_dir"/"v$version/$exec_entrypoint")" #2>/dev/null clean_res=$? if [[ $clean_res -eq 0 ]] ; then { - printf "\033[0;32m[DELETE] Success on ( $version ).\e[0m\n" + log_cl "[DELETE] Success on ( $version )." info app "$(echo_node deleting delete_success)" app "$(echo_node delete_success end_node)" end_digraph } else { - printf "\033[0;31m[DELETE] Failure on ( $version ).\e[0m\n" + log_cl "[DELETE] Failure on ( $version )." error app "$(echo_node deleting delete_fail)" app "$(echo_node delete_fail end_node)" end_digraph @@ -2530,19 +2782,24 @@ amboso_parse_args() { packm="" ignore_gitcheck="" showtimem="" + plainm="" + loggedm="" + [[ $do_filelog_flag -gt 0 ]] && loggedm="J" + [[ $allow_color_flag -le 0 ]] && plainm="P" [[ $show_time_flag -gt 0 ]] && showtimem="w" [[ $ignore_git_check_flag -gt 0 ]] && ignore_gitcheck="X" [[ $pack_flag -gt 0 ]] && packm="z" [[ $silent_flag -gt 0 ]] && silentm="s" - [[ $verbose_flag -gt 0 ]] && verb="V" && printf "\n[PURGE] Trying to delete ( $purge_vers ) ( $(($i+1)) / $tot_vers )\n" >&2 + [[ $verbose_flag -ne 3 ]] && verb="-V $verbose_flag" + [[ $verbose_flag -gt 3 ]] && printf "\n[PURGE] Trying to delete ( $purge_vers ) ( $(($i+1)) / $tot_vers )\n" >&2 [[ $base_mode_flag -gt 0 ]] && basem="B" #We make sure to pass on eventual base mode to the subcalls [[ $git_mode_flag -gt 0 ]] && gitm="g" #We make sure to pass on eventual git mode to the subcalls [[ $quiet_flag -gt 0 ]] && quietm="q" #We make sure to pass on eventual quiet flag mode to the subcalls if [[ $quiet_flag -eq 0 ]] ; then { - printf "\033[1;35m[PURGE] Running \"$(basename "$prog_name") -Y $amboso_start_time-M $makefile_version -S $source_name -E $exec_entrypoint -D $scripts_dir -d$verb$gitm$basem$quietm$silentm$packm$ignore_gitcheck$showtimem $purge_vers 2>/dev/null\"\e[0m\n" + log_cl "[PURGE] Running \"$(basename "$prog_name") -Y $amboso_start_time-M $makefile_version -S $source_name -E $exec_entrypoint -D $scripts_dir $verb -d$gitm$basem$quietm$silentm$packm$ignore_gitcheck$showtimem$plainm$loggedm $purge_vers 2>/dev/null\"" debug } fi - ( $prog_name -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -E "$exec_entrypoint" -D "$scripts_dir" -d"$verb""$gitm""$basem""$quietm""$silentm""$packm""$ignore_gitcheck""$showtimem" "$purge_vers" ) 2>/dev/null + ( $prog_name -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -E "$exec_entrypoint" -D "$scripts_dir" $verb -d"$gitm""$basem""$quietm""$silentm""$packm""$ignore_gitcheck""$showtimem""$plainm""$loggedm" "$purge_vers" ) 2>/dev/null clean_res="$?" #To be sure delete OP is gonna be the returning op here, we assume pack just never makes the script return, so it will always go to delete OP safely. @@ -2550,19 +2807,19 @@ amboso_parse_args() { if [[ $clean_res -eq 0 && $has_bin -gt 0 ]] ; then { #we advance the count tot_removed=$(($tot_removed +1)) - [[ $verbose_flag -gt 0 ]] && printf "\033[0;33m[PURGE] Removed ( $purge_vers ) using ( $tool_txt ).\e[0m\n" >&2 + [[ $verbose_flag -gt 3 ]] && log_cl "[PURGE] Removed ( $purge_vers ) using ( $tool_txt )." debug >&2 } else { verbose_hint="" [[ $verbose_flag -lt 1 ]] && verbose_hint="Run with -V to see more info." - printf "\n\033[1;31m[PURGE] Failed delete for ( $purge_vers ) binary. $verbose_hint\e[0m\n\n" - [[ $verbose_flag -gt 0 ]] && printf "\033[0;31m[PURGE] Failed removing ( $purge_vers ) using ( $tool_txt ). $verbose_hint\e[0m\n" #>&2 + log_cl "[PURGE] Failed delete for ( $purge_vers ) binary. $verbose_hint\n" error + [[ $verbose_flag -gt 3 ]] && log_cl "[PURGE] Failed removing ( $purge_vers ) using ( $tool_txt ). $verbose_hint" error #>&2 #try deleting again to get more output, since we discarded stderr before # #we could just pass -v to the first call if we have it on - if [[ $verbose_flag -gt 0 ]]; then { + if [[ $verbose_flag -gt 3 ]]; then { printf "[PURGE] Verbose flag was asserted as ($verbose_flag).\n" >&2 - printf "[PURGE] Checking errors, running \033[1;33m$(basename "$prog_name") -V 2 -d $purge_vers\e[0m.\n" >&2 - ("$prog_name" -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -D "$scripts_dir" -E "$exec_entrypoint" -V 2 -d"$gitm""$basem""$ignore_gitcheck""$showtimem" "$purge_vers") #>&2 + log_cl "[PURGE] Checking errors, running $(basename "$prog_name") -V 2 -d $purge_vers" debug >&2 + ("$prog_name" -Y "$amboso_start_time" -M "$makefile_version" -S "$source_name" -D "$scripts_dir" -E "$exec_entrypoint" -V 2 -d"$gitm""$basem""$ignore_gitcheck""$showtimem""$plainm""$loggedm" "$purge_vers") #>&2 } fi } @@ -2570,11 +2827,11 @@ amboso_parse_args() { done if [[ $tot_removed -gt 0 ]] ; then { - printf "\033[0;33m[PURGE] Purged ( $tot_removed / $tot_vers ) versions, quitting.\e[0m\n\n" + log_cl "[PURGE] Purged ( $tot_removed / $tot_vers ) versions, quitting.\n" info app "$(echo_node purging purging_success)" app "$(echo_node purging_success end_node)" } else { - printf "\n\033[0;33m[PURGE] No binaries to purge found.\e[0m\n\n" + log_cl "[PURGE] No binaries to purge found.\n" info app "$(echo_node purging purging_fail)" app "$(echo_node purging_fail end_node)" } @@ -2607,37 +2864,47 @@ amboso_main() { printf "COMMAND: {$cmd}\n" if [[ $cmd = "quit" ]] ; then { unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED exit 0 } fi if [[ $cmd = "version" ]] ; then { (amboso_parse_args "-v") unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED return } fi if [[ $cmd = "build" ]] ; then { (amboso_parse_args "-Xb" "latest") unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED return } fi if [[ $cmd = "init" ]] ; then { (amboso_init_proj "$2") unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED return } fi if [[ $cmd = "help" ]] ; then { - printf "\033[1;35m[AMBOSO-MAIN]\033[0m Quick commands:\n\n" + log_cl "[AMBOSO-MAIN] Quick commands:\n" info printf " build Build latest version\n\n" printf " init Prepare current dir for an amboso project\n\n" printf " version Print amboso version\n\n" printf " quit Quit amboso\n\n" printf " help Print this message\n\n" - printf "\033[1;35m[AMBOSO-MAIN]\033[0m Amboso help (-h):\n\n" + log_cl "[AMBOSO-MAIN] Amboso help (-h):\n" info (amboso_parse_args "-Xh") unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED return } fi @@ -2646,58 +2913,69 @@ amboso_main() { (amboso_parse_args "$@") res="$?" unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED return "$res" - } else { # Repl - while read -re -p "[AMBOSO-MAIN]$ " line ; - do { - cmd="$(printf -- "${line}" | cut -f1 -d'-')" - if [[ ! -z $cmd ]] ; then { - printf "COMMAND: {$cmd}\n" - if [[ $cmd = "quit" ]] ; then { - unset AMBOSO_LVL_REC - exit 0 - } - fi - if [[ $cmd = "version" ]] ; then { - (amboso_parse_args "-v") - unset AMBOSO_LVL_REC - return + } else { # Try doing make + (amboso_parse_args "$@") + unset AMBOSO_LVL_REC + unset AMBOSO_COLOR + unset AMBOSO_LOGGED + return "$?" - } - fi - if [[ $cmd = "build" ]] ; then { - (amboso_parse_args "-Xb" "latest") - unset AMBOSO_LVL_REC - return - } - fi - if [[ $cmd = "init" ]] ; then { - (amboso_init_proj "$2") - unset AMBOSO_LVL_REC - return - } - fi - if [[ $cmd = "help" ]] ; then { - printf "\033[1;35m[AMBOSO-MAIN]\033[0m Quick commands:\n\n" - printf " build Build latest version\n\n" - printf " init Prepare current dir for an amboso project\n\n" - printf " version Print amboso version\n\n" - printf " quit Quit amboso\n\n" - printf " help Print this message\n\n" - printf "\033[1;35m[AMBOSO-MAIN]\033[0m Amboso help (-h):\n\n" - (amboso_parse_args "-Xh") - unset AMBOSO_LVL_REC - return - } - fi - } - fi - printf "\033[1;35m[CMDLINE]\033[0m \"\033[1;36m$line\033[0m\"\n" - (amboso_parse_args "$line") - res="$?" - unset AMBOSO_LVL_REC - } - done < "${1:-/dev/stdin}" + # Legacy: REPL + #TODO: move repl + # + #while read -re -p "[AMBOSO-MAIN]$ " line ; + #do { + # cmd="$(printf -- "${line}" | cut -f1 -d'-')" + # if [[ ! -z $cmd ]] ; then { + # printf "COMMAND: {$cmd}\n" + # if [[ $cmd = "quit" ]] ; then { + # unset AMBOSO_LVL_REC + # exit 0 + # } + # fi + # if [[ $cmd = "version" ]] ; then { + # (amboso_parse_args "-v") + # unset AMBOSO_LVL_REC + # return + + # } + # fi + # if [[ $cmd = "build" ]] ; then { + # (amboso_parse_args "-Xb" "latest") + # unset AMBOSO_LVL_REC + # return + # } + # fi + # if [[ $cmd = "init" ]] ; then { + # (amboso_init_proj "$2") + # unset AMBOSO_LVL_REC + # return + # } + # fi + # if [[ $cmd = "help" ]] ; then { + # printf "\033[1;35m[AMBOSO-MAIN]\033[0m Quick commands:\n\n" + # printf " build Build latest version\n\n" + # printf " init Prepare current dir for an amboso project\n\n" + # printf " version Print amboso version\n\n" + # printf " quit Quit amboso\n\n" + # printf " help Print this message\n\n" + # printf "\033[1;35m[AMBOSO-MAIN]\033[0m Amboso help (-h):\n\n" + # (amboso_parse_args "-Xh") + # unset AMBOSO_LVL_REC + # return + # } + # fi + # } + # fi + # printf "\033[1;35m[CMDLINE]\033[0m \"\033[1;36m$line\033[0m\"\n" + # (amboso_parse_args "$line") + # res="$?" + # unset AMBOSO_LVL_REC + #} + #done < "${1:-/dev/stdin}" } fi diff --git a/bin/stego.lock b/bin/stego.lock index 4d8982d..b01d88d 100644 --- a/bin/stego.lock +++ b/bin/stego.lock @@ -3,7 +3,7 @@ source = "hello_world.c" bin = "hello_world" makevers = "0.3.0" -automakevers = "2.0.0" +automakevers = "3.0.0" tests = "kazoj" [ tests ] @@ -13,8 +13,8 @@ errortestsdir = "kulpo" [ versions ] -"-0.1.0" = " < 0.3.0, does not have Makefile" -"-0.9.0" = "> 0.3.0, has Makefile" +"B0.1.0" = " < 0.3.0, does not have Makefile" +"B0.9.0" = "> 0.3.0, has Makefile" "1.0.0" = "First version with git mode support" "1.1.0" = "Introduced delete mode" "1.1.2" = "( Hotfix ) Introduced list versions flag" @@ -24,8 +24,7 @@ errortestsdir = "kulpo" "1.3.2" = "foo" "1.4.9" = "Pass silent flag to init and purge" "1.5.2" = "Dump sysinfo" -"1.6.0" = "Try running autoconf and ./configure" -"1.6.2" = "-G to gen C header, check remote tags" +"1.6.2" = "-G to gen C header, check remote tags. Run autoconf and ./configure" "1.6.3" = "Better -G gen" "1.6.4" = "Gen C header for missing git tags drops errors" "1.6.5" = "Add global start time" @@ -49,3 +48,4 @@ errortestsdir = "kulpo" "1.9.7" = "Use -v instead of -e for escaping" "1.9.8" = "Fix init subcommand by trying to mkdir target dir" "1.9.9" = "-C flag expects a file to read config args" +"2.0.0" = "New flags, proper colored output" diff --git a/bin/1.6.0/.gitignore b/bin/v2.0.0/.gitignore similarity index 100% rename from bin/1.6.0/.gitignore rename to bin/v2.0.0/.gitignore diff --git a/kazoj/bone/anvil_stego b/kazoj/bone/anvil_stego deleted file mode 100755 index 0daeb0a..0000000 --- a/kazoj/bone/anvil_stego +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# - -./amboso -qx ./stego-examples/lock.stego diff --git a/kazoj/bone/anvil_stego.k b/kazoj/bone/anvil_stego.k new file mode 100755 index 0000000..06b635c --- /dev/null +++ b/kazoj/bone/anvil_stego.k @@ -0,0 +1,4 @@ +#!/bin/bash +# + +./amboso -Pqx ./stego-examples/lock.stego diff --git a/kazoj/bone/anvil_stego.stderr b/kazoj/bone/anvil_stego.k.stderr similarity index 100% rename from kazoj/bone/anvil_stego.stderr rename to kazoj/bone/anvil_stego.k.stderr diff --git a/kazoj/bone/anvil_stego.stdout b/kazoj/bone/anvil_stego.k.stdout similarity index 100% rename from kazoj/bone/anvil_stego.stdout rename to kazoj/bone/anvil_stego.k.stdout diff --git a/kazoj/bone/good_stego b/kazoj/bone/good_stego deleted file mode 100755 index a261ede..0000000 --- a/kazoj/bone/good_stego +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# - -./amboso -qlx ./stego-examples/good.stego diff --git a/kazoj/bone/good_stego.k b/kazoj/bone/good_stego.k new file mode 100755 index 0000000..946b14f --- /dev/null +++ b/kazoj/bone/good_stego.k @@ -0,0 +1,4 @@ +#!/bin/bash +# + +./amboso -Pqlx ./stego-examples/good.stego diff --git a/kazoj/bone/good_stego.stderr b/kazoj/bone/good_stego.k.stderr similarity index 100% rename from kazoj/bone/good_stego.stderr rename to kazoj/bone/good_stego.k.stderr diff --git a/kazoj/bone/good_stego.k.stdout b/kazoj/bone/good_stego.k.stdout new file mode 100644 index 0000000..3bf285a --- /dev/null +++ b/kazoj/bone/good_stego.k.stdout @@ -0,0 +1 @@ +[LINT] { Success on: "./stego-examples/good.stego" } diff --git a/kazoj/bone/good_stego.stdout b/kazoj/bone/good_stego.stdout deleted file mode 100644 index f5246bd..0000000 --- a/kazoj/bone/good_stego.stdout +++ /dev/null @@ -1 +0,0 @@ -[LINT] { Success on: "./stego-examples/good.stego" } diff --git a/kazoj/bone/good_vers b/kazoj/bone/good_vers deleted file mode 100755 index ce0a598..0000000 --- a/kazoj/bone/good_vers +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -"./amboso" -D "./bin" -qX 1.0.0 diff --git a/kazoj/bone/good_vers.k b/kazoj/bone/good_vers.k new file mode 100755 index 0000000..cf1a0f6 --- /dev/null +++ b/kazoj/bone/good_vers.k @@ -0,0 +1,2 @@ +#!/bin/bash +"./amboso" -D "./bin" -PqX 1.0.0 diff --git a/kazoj/bone/good_vers.k.stderr b/kazoj/bone/good_vers.k.stderr new file mode 100644 index 0000000..d9df6ac --- /dev/null +++ b/kazoj/bone/good_vers.k.stderr @@ -0,0 +1,2 @@ +[DEBUG] To try building, run with -b flag + diff --git a/kazoj/bone/good_vers.k.stdout b/kazoj/bone/good_vers.k.stdout new file mode 100644 index 0000000..717454c --- /dev/null +++ b/kazoj/bone/good_vers.k.stdout @@ -0,0 +1 @@ +[QUERY] ( 1.0.0 ) binary not found in ( ./binv1.0.0 ). diff --git a/kazoj/bone/good_vers.stderr b/kazoj/bone/good_vers.stderr deleted file mode 100644 index 0b2a752..0000000 --- a/kazoj/bone/good_vers.stderr +++ /dev/null @@ -1,2 +0,0 @@ -[DEBUG] To try building, run with -b flag - diff --git a/kazoj/bone/good_vers.stdout b/kazoj/bone/good_vers.stdout deleted file mode 100644 index 62e570c..0000000 --- a/kazoj/bone/good_vers.stdout +++ /dev/null @@ -1,2 +0,0 @@ - -[QUERY] ( 1.0.0 ) binary not found in ( ./binv1.0.0 ). diff --git a/kazoj/bone/lint_anvil_stego b/kazoj/bone/lint_anvil_stego deleted file mode 100755 index 4e9cda3..0000000 --- a/kazoj/bone/lint_anvil_stego +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# - -./amboso -qlx ./bin/stego.lock diff --git a/kazoj/bone/lint_anvil_stego.k b/kazoj/bone/lint_anvil_stego.k new file mode 100755 index 0000000..a0afad5 --- /dev/null +++ b/kazoj/bone/lint_anvil_stego.k @@ -0,0 +1,4 @@ +#!/bin/bash +# + +./amboso -Pqlx ./bin/stego.lock diff --git a/kazoj/bone/lint_anvil_stego.stderr b/kazoj/bone/lint_anvil_stego.k.stderr similarity index 100% rename from kazoj/bone/lint_anvil_stego.stderr rename to kazoj/bone/lint_anvil_stego.k.stderr diff --git a/kazoj/bone/lint_anvil_stego.k.stdout b/kazoj/bone/lint_anvil_stego.k.stdout new file mode 100644 index 0000000..30ee3ae --- /dev/null +++ b/kazoj/bone/lint_anvil_stego.k.stdout @@ -0,0 +1 @@ +[LINT] { Success on: "./bin/stego.lock" } diff --git a/kazoj/bone/lint_anvil_stego.stdout b/kazoj/bone/lint_anvil_stego.stdout deleted file mode 100644 index 91691d6..0000000 --- a/kazoj/bone/lint_anvil_stego.stdout +++ /dev/null @@ -1 +0,0 @@ -[LINT] { Success on: "./bin/stego.lock" } diff --git a/kazoj/bone/runtimes b/kazoj/bone/runtimes.k similarity index 97% rename from kazoj/bone/runtimes rename to kazoj/bone/runtimes.k index ad3d739..cf1ca96 100644 --- a/kazoj/bone/runtimes +++ b/kazoj/bone/runtimes.k @@ -4,7 +4,7 @@ function run_args_gt { args="$1" target="$2" tstart=`date +%s.%N` - ./amboso -B$args >/dev/null 2>/dev/null + ./amboso -BP$args >/dev/null 2>/dev/null run_exitcode="$?" tend=`date +%s.%N` runtime=$( echo "$tend - $tstart" | bc -l ) diff --git a/kazoj/bone/runtimes.stderr b/kazoj/bone/runtimes.k.stderr similarity index 100% rename from kazoj/bone/runtimes.stderr rename to kazoj/bone/runtimes.k.stderr diff --git a/kazoj/bone/runtimes.stdout b/kazoj/bone/runtimes.k.stdout similarity index 100% rename from kazoj/bone/runtimes.stdout rename to kazoj/bone/runtimes.k.stdout diff --git a/kazoj/bone/try_amboso_sourcing b/kazoj/bone/try_amboso_sourcing deleted file mode 100755 index 7486f4b..0000000 --- a/kazoj/bone/try_amboso_sourcing +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash - -expected_AMBOSO_API_LVL="1.9.9" - -verbose_flag=1 -tell_uname_flag=0 -quiet_flag=0 -#Function to try sourcing amboso_fn.sh -source_amboso_api() { - if [ "$(basename "$(pwd)")" = "amboso" ] ; then { - amboso_fn_path="$(realpath "$(pwd)")/amboso_fn.sh" - if [ -f "$amboso_fn_path" ] ; then { - [ "$verbose_flag" -gt 1 ] && printf "\033[0;35m[PREP] Running inside amboso dir. Sourcing: \"%s\".\e[0m\n" "$amboso_fn_path">&2 - # shellcheck source=./amboso_fn.sh - . "${amboso_fn_path}"; - source_res="$?" - if [ "$source_res" -ne 0 ] ; then { - printf "\033[1;31m[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 - exit 3 - } - fi - } else { - printf "\033[1;31m[ERROR] Couldn't load amboso_fn, check your symlinks.\e[0m\n" - exit 2 - } - fi - } else { - amboso_fn_path="$(realpath "$(pwd)")/amboso/amboso_fn.sh" - found_amboso_dir=0 - [ "$verbose_flag" -gt 1 ] && printf "\033[0;33m[PREP] Assuming we are running in super-repo. Sourcing: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 - [ -d "$(realpath "$(pwd)")"/amboso ] && found_amboso_dir=1 - [ "$verbose_flag" -gt 1 ] && [ "$found_amboso_dir" -gt 0 ] && printf "\033[0;32m[PREP] Found amboso dir.\e[0m\n" >&2 - if [ -f "$amboso_fn_path" ] ; then { - [ "$verbose_flag" -gt 1 ] && printf "\033[0;35m[PREP] Valid file at: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 - # shellcheck source=./amboso_fn.sh - . "${amboso_fn_path}"; - source_res="$?" - [ "$source_res" -ne 0 ] && printf "\033[1;31m[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 - } else { - [ "$quiet_flag" -eq 0 ] && printf "\033[0;31m[WARN] \"%s\" was not a valid file. Not in valid super-repo.\e[0m\n" "$amboso_fn_path" >&2 - try_default=1 - } - fi - if [ "$try_default" -eq 1 ] && [ -f "/usr/local/bin/amboso_fn.sh" ] ; then { #We only enter here if we failed sourcing - #We need one more error message to show me are missing functions because of an amboso directory with no file. - if [ "$found_amboso_dir" -gt 0 ] ; then { - printf "\033[1;31m[WARN] Deprecated amboso dir (< 1.4.3) found, as it doesn't provide a function api marker.\e[0m\n\n" >&2 - exit 3 - } - fi - amboso_fn_path="/usr/local/bin/amboso_fn.sh" - [ "$quiet_flag" -eq 0 ] && printf "\033[0;35m[WARN] Fallback to default path for amboso_fn. Sourcing: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 - # shellcheck source=/usr/local/bin/amboso_fn.sh - . "$amboso_fn_path"; - source_res="$?" - if [ "$source_res" -ne 0 ] ; then { - printf "\033[1;31m[PREP] Failed loading amboso_fn. Quitting.\n\n Using file: \"%s\".\e[0m\n" "$amboso_fn_path" >&2 - exit 3 - } - fi - } - fi - } - fi - - if [ "$source_res" -ne 0 ] ; then { - printf "\033[1;31m[PANIC] Failed sourcing amboso_fn. Expected path: \"%s\".\e[0m\n" "$amboso_fn_path" - exit 2 - } - fi - [ "$verbose_flag" -gt 1 ] && printf "\033[0;32m[PREP] Done loading functions.\e[0m\n" >&2 - [ "$verbose_flag" -gt 1 ] && printf "\033[0;37m[PREP] \"\$AMBOSO_API_LVL\" is: (\033[0;34m %s \033[0;37m, expected { \033[1;33m%s\033[0;37m } ).\e[0m\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 - [ "$tell_uname_flag" -eq 1 ] && print_sysinfo - if expr "'$expected_AMBOSO_API_LVL" \> "'$AMBOSO_API_LVL" >/dev/null ; then { - printf "\033[1;31m[PANIC] AMBOSO_API_LVL not supported. Needed { \033[1;35m%s\033[1;31m } , { \033[1;33m%s\033[1;31m } is too low.\n\n Maybe check your \"amboso_fn.sh\" file.\n\e[0m\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" - printf "\033[1;31m[PANIC] Couldn't load functions. Quitting.\e[0m\n" - exit 2 - } elif expr "'$AMBOSO_API_LVL" \> "'$expected_AMBOSO_API_LVL" >/dev/null ; then { - [ "$verbose_flag" -gt 0 ] && printf "\033[0;31m[WARN] AMBOSO_API_LVL is greater than expected. Needed { \033[1;35m%s\033[0;31m } , { \033[1;34m%s\033[0;31m } is higher.\e[0m\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" >&2 - [ "$verbose_flag" -gt 0 ] && printf "\n\033[1;31m[WARN] Continuing run with unexpected AMBOSO_API_LVL: Needed { \033[1;35m%s\033[1;31m } , { \033[1;34m%s\033[1;31m } is higher.\e[0m\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" - #exit 2 - } elif [ "$AMBOSO_API_LVL" = "$expected_AMBOSO_API_LVL" ] ; then { - [ "$verbose_flag" -gt 0 ] && printf "\033[0;32m[PREP] Running with \"\$AMBOSO_API_LVL\" [ \033[1;35m%s\033[0;32m ]; min is { \033[1;36m%s\033[0;32m }.\e[0m\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 - } - fi -} - -printf "[TEST] source_amboso_api()\n" -source_amboso_api -printf "[RES] {$?}\n" diff --git a/kazoj/bone/try_amboso_sourcing.k b/kazoj/bone/try_amboso_sourcing.k new file mode 100755 index 0000000..883422e --- /dev/null +++ b/kazoj/bone/try_amboso_sourcing.k @@ -0,0 +1,105 @@ +#!/bin/bash + +expected_AMBOSO_API_LVL="2.0.0" + +verbose_flag=1 +tell_uname_flag=0 +quiet_flag=0 +#Function to try sourcing amboso_fn.sh +source_amboso_api() { + if [ "$(basename "$(pwd)")" = "amboso" ] ; then { + amboso_fn_path="$(realpath "$(pwd)")/amboso_fn.sh" + if [ -f "$amboso_fn_path" ] ; then { + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Running inside amboso dir. Sourcing: \"%s\".\n" "$amboso_fn_path">&2 + # shellcheck source=./amboso_fn.sh + . "${amboso_fn_path}"; + source_res="$?" + if [ "$source_res" -ne 0 ] ; then { + printf "[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\n" "$amboso_fn_path" >&2 + exit 3 + } + fi + } else { + printf "[ERROR] Could not load amboso_fn, check your symlinks.\e[0m\n" + exit 2 + } + fi + } else { + amboso_fn_path="$(realpath "$(pwd)")/amboso/amboso_fn.sh" + found_amboso_dir=0 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Assuming we are running in super-repo. Sourcing: \"%s\".\n" "$amboso_fn_path" >&2 + if [ -d "$(realpath "$(pwd)")"/amboso ]; then { + found_amboso_dir=1 + } + fi + [ "$verbose_flag" -gt 1 ] && [ "$found_amboso_dir" -gt 0 ] && printf "[PREP] Found amboso dir.\n" >&2 + if [ -f "$amboso_fn_path" ] ; then { + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Valid file at: \"%s\".\n" "$amboso_fn_path" >&2 + # shellcheck source=./amboso_fn.sh + . "${amboso_fn_path}"; + source_res="$?" + [ "$source_res" -ne 0 ] && printf "[PREP] Failed loading amboso_fn.\n\n Using file: \"%s\".\n" "$amboso_fn_path" >&2 + } else { + [ "$quiet_flag" -eq 0 ] && printf "[WARN] \"%s\" was not a valid file. Not in valid super-repo.\n" "$amboso_fn_path" >&2 + try_default=1 + } + fi + if [ "$try_default" -eq 1 ] && [ -f "/usr/local/bin/amboso_fn.sh" ] ; then { #We only enter here if we failed sourcing + #We need one more error message to show me are missing functions because of an amboso directory with no file. + if [ "$found_amboso_dir" -gt 0 ] ; then { + printf "[WARN] Deprecated amboso dir (< 1.4.3) found, as it doesn't provide a function api marker.\n" >&2 + exit 3 + } + fi + amboso_fn_path="/usr/local/bin/amboso_fn.sh" + [ "$quiet_flag" -eq 0 ] && printf "[WARN] Fallback to default path for amboso_fn. Sourcing: \"%s\".\n" "$amboso_fn_path" >&2 + # shellcheck source=/usr/local/bin/amboso_fn.sh + . "$amboso_fn_path"; + source_res="$?" + if [ "$source_res" -ne 0 ] ; then { + printf "[PREP] Failed loading amboso_fn. Quitting.\n\n Using file: \"%s\".\n" "$amboso_fn_path" >&2 + exit 3 + } + fi + } + fi + } + fi + + if [ "$source_res" -ne 0 ] ; then { + printf "[PANIC] Failed sourcing amboso_fn. Expected path: \"%s\".\n" "$amboso_fn_path" + exit 2 + } + fi + [ "$verbose_flag" -gt 1 ] && printf "[PREP] Done loading functions.\n" >&2 + [ "$verbose_flag" -gt 1 ] && printf "[PREP] \"\$AMBOSO_API_LVL\" is: ( %s , expected { %s } ).\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 + [ "$tell_uname_flag" -eq 1 ] && print_sysinfo + if expr "'$expected_AMBOSO_API_LVL" \> "'$AMBOSO_API_LVL" >/dev/null ; then { + printf "[PANIC] AMBOSO_API_LVL not supported. Needed { %s } , { %s } is too low.\n\n Maybe check your \"amboso_fn.sh\" file.\n\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" + if [[ "$AMBOSO_API_LVL" < "1.4.3" ]] ; then { + printf "[WARN] amboso_fn.sh does not contain AMBOSO_API_LVL.\n" + } elif [[ "$AMBOSO_API_LVL" > "1.4.2" && "$AMBOSO_API_LVL" < "1.6.6" ]] ; then { + printf "[WARN] Unstable amboso version detected.\n" + } elif [[ "$AMBOSO_API_LVL" > "1.6.5" && "$AMBOSO_API_LVL" < "1.7.4" ]] ; then { + printf "[WARN] Legacy stego.lock format is not supported.\n" + } elif [[ "$AMBOSO_API_LVL" > "1.7.4" && "$AMBOSO_API_LVL" < "1.9.6" ]] ; then { + printf "[WARN] Incompatible -C flag, test mode\n" + } elif [[ "$AMBOSO_API_LVL" < "2.0.0" ]] ; then { + printf "[WARN] Deprecated amboso 1.x API found.\n" + } + fi + printf "[PANIC] Could not load functions. Quitting.\n" + exit 2 + } elif expr "'$AMBOSO_API_LVL" \> "'$expected_AMBOSO_API_LVL" >/dev/null ; then { + [ "$verbose_flag" -gt 0 ] && printf "[WARN] AMBOSO_API_LVL is greater than expected. Needed { %s } , { %s } is higher.\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" >&2 + [ "$verbose_flag" -gt 0 ] && printf "\n[WARN] Continuing run with unexpected AMBOSO_API_LVL: Needed { %s } , { %s } is higher.\n" "$expected_AMBOSO_API_LVL" "$AMBOSO_API_LVL" + #exit 2 + } elif [ "$AMBOSO_API_LVL" = "$expected_AMBOSO_API_LVL" ] ; then { + [ "$verbose_flag" -gt 0 ] && printf "[PREP] Running with \"\$AMBOSO_API_LVL\" [ %s ]; min is { %s }.\e[0m\n" "$AMBOSO_API_LVL" "$expected_AMBOSO_API_LVL" >&2 + } + fi +} + +printf "[TEST] source_amboso_api()\n" +source_amboso_api +printf "[RES] {$?}\n" diff --git a/kazoj/bone/try_amboso_sourcing.k.stderr b/kazoj/bone/try_amboso_sourcing.k.stderr new file mode 100644 index 0000000..d4a98a2 --- /dev/null +++ b/kazoj/bone/try_amboso_sourcing.k.stderr @@ -0,0 +1 @@ +[PREP] Running with "$AMBOSO_API_LVL" [ 2.0.0 ]; min is { 2.0.0 }. diff --git a/kazoj/bone/try_amboso_sourcing.stdout b/kazoj/bone/try_amboso_sourcing.k.stdout similarity index 100% rename from kazoj/bone/try_amboso_sourcing.stdout rename to kazoj/bone/try_amboso_sourcing.k.stdout diff --git a/kazoj/bone/try_amboso_sourcing.stderr b/kazoj/bone/try_amboso_sourcing.stderr deleted file mode 100644 index 19d6438..0000000 --- a/kazoj/bone/try_amboso_sourcing.stderr +++ /dev/null @@ -1 +0,0 @@ -[PREP] Running with "$AMBOSO_API_LVL" [ 1.9.9 ]; min is { 1.9.9 }. diff --git a/kazoj/bone/vershw b/kazoj/bone/vershw.k similarity index 100% rename from kazoj/bone/vershw rename to kazoj/bone/vershw.k diff --git a/kazoj/bone/vershw.stderr b/kazoj/bone/vershw.k.stderr similarity index 100% rename from kazoj/bone/vershw.stderr rename to kazoj/bone/vershw.k.stderr diff --git a/kazoj/bone/vershw.stdout b/kazoj/bone/vershw.k.stdout similarity index 100% rename from kazoj/bone/vershw.stdout rename to kazoj/bone/vershw.k.stdout diff --git a/kazoj/kulpo/bad_stego b/kazoj/kulpo/bad_stego deleted file mode 100755 index 66c49f2..0000000 --- a/kazoj/kulpo/bad_stego +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# - -./amboso -qlx ./stego-examples/bad.stego diff --git a/kazoj/kulpo/bad_stego.k b/kazoj/kulpo/bad_stego.k new file mode 100755 index 0000000..c58e919 --- /dev/null +++ b/kazoj/kulpo/bad_stego.k @@ -0,0 +1,4 @@ +#!/bin/bash +# + +./amboso -Pqlx ./stego-examples/bad.stego diff --git a/kazoj/kulpo/bad_stego.k.stderr b/kazoj/kulpo/bad_stego.k.stderr new file mode 100644 index 0000000..258b673 --- /dev/null +++ b/kazoj/kulpo/bad_stego.k.stderr @@ -0,0 +1,27 @@ +[LINT] Invalid line: $hey = you +[LINT] Invalid line: hi/ = err +[LINT] Invalid line: \mine = evl +[LINT] Invalid line: - "# error4" +[LINT] Invalid line: hey "# error5" +[LINT] Invalid left side (contains spaces or disallowed characters): hash#tag +[LINT] Invalid line: under_score = 1 +[LINT] Invalid line: "1_foo" = ba +[LINT] Invalid line: {} +[LINT] Invalid line: unclosed-curly = {"this" +[LINT] Invalid line: yoink {$} +[LINT] Invalid line: - = farvalue +[LINT] Invalid line: 100 = str +[LINT] Invalid line: val = "myval#" +[LINT] Invalid line: "val" = "myval#" +[LINT] Invalid line: - +[LINT] Invalid line: test +[LINT] Invalid line: " = try +[LINT] Invalid line: [ NO SPACES_ALLOWED ] +[LINT] Invalid line: [ no_missing_square_bracket +[LINT] Invalid line: [-NO-DASHES] +[LINT] Invalid line: [-NOCAPS] +[LINT] Invalid line: no[way]man +[LINT] Invalid line: no = "[way] man" +[LINT] Invalid line: [oh[no]] +[LINT] Invalid line: [oh]=no +[LEX] Errors while lexing. diff --git a/kazoj/kulpo/bad_stego.k.stdout b/kazoj/kulpo/bad_stego.k.stdout new file mode 100644 index 0000000..2674c0c --- /dev/null +++ b/kazoj/kulpo/bad_stego.k.stdout @@ -0,0 +1,2 @@ +[CHECK] Errors occurred during lexing. +[LINT] { Failure on: "./stego-examples/bad.stego" } diff --git a/kazoj/kulpo/bad_stego.stderr b/kazoj/kulpo/bad_stego.stderr deleted file mode 100644 index 9f54634..0000000 --- a/kazoj/kulpo/bad_stego.stderr +++ /dev/null @@ -1,27 +0,0 @@ -[LINT] Invalid line: $hey = you  -[LINT] Invalid line: hi/ = err  -[LINT] Invalid line: \mine = evl  -[LINT] Invalid line: - "# error4" -[LINT] Invalid line: hey "# error5" -[LINT] Invalid left side (contains spaces or disallowed characters): hash#tag -[LINT] Invalid line: under_score = 1  -[LINT] Invalid line: "1_foo" = ba  -[LINT] Invalid line: {}  -[LINT] Invalid line: unclosed-curly = {"this"  -[LINT] Invalid line: yoink {$}  -[LINT] Invalid line: - = farvalue  -[LINT] Invalid line: 100 = str  -[LINT] Invalid line: val = "myval#"  -[LINT] Invalid line: "val" = "myval#"  -[LINT] Invalid line: -  -[LINT] Invalid line: test  -[LINT] Invalid line: " = try  -[LINT] Invalid line: [ NO SPACES_ALLOWED ] -[LINT] Invalid line: [ no_missing_square_bracket -[LINT] Invalid line: [-NO-DASHES] -[LINT] Invalid line: [-NOCAPS] -[LINT] Invalid line: no[way]man -[LINT] Invalid line: no = "[way] man" -[LINT] Invalid line: [oh[no]] -[LINT] Invalid line: [oh]=no -[LEX] Errors while lexing. diff --git a/kazoj/kulpo/bad_stego.stdout b/kazoj/kulpo/bad_stego.stdout deleted file mode 100644 index 22ad18c..0000000 --- a/kazoj/kulpo/bad_stego.stdout +++ /dev/null @@ -1,2 +0,0 @@ -[CHECK] Errors occurred during lexing. -[LINT] { Failure on: "./stego-examples/bad.stego" } diff --git a/kazoj/kulpo/bad_vers b/kazoj/kulpo/bad_vers deleted file mode 100755 index d3cb586..0000000 --- a/kazoj/kulpo/bad_vers +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -"./amboso" -D "./bin" -qX 69 diff --git a/kazoj/kulpo/bad_vers.k b/kazoj/kulpo/bad_vers.k new file mode 100755 index 0000000..0874c64 --- /dev/null +++ b/kazoj/kulpo/bad_vers.k @@ -0,0 +1,2 @@ +#!/bin/bash +"./amboso" -D "./bin" -PqX 69 diff --git a/kazoj/kulpo/bad_vers.stderr b/kazoj/kulpo/bad_vers.k.stderr similarity index 100% rename from kazoj/kulpo/bad_vers.stderr rename to kazoj/kulpo/bad_vers.k.stderr diff --git a/kazoj/kulpo/bad_vers.k.stdout b/kazoj/kulpo/bad_vers.k.stdout new file mode 100644 index 0000000..982155f --- /dev/null +++ b/kazoj/kulpo/bad_vers.k.stdout @@ -0,0 +1,4 @@ +[ERROR] ( 69 ) is not a supported tag. + +[ERROR] Run with -h for help. + diff --git a/kazoj/kulpo/bad_vers.stdout b/kazoj/kulpo/bad_vers.stdout deleted file mode 100644 index 1d8245a..0000000 --- a/kazoj/kulpo/bad_vers.stdout +++ /dev/null @@ -1,4 +0,0 @@ -[ERROR] ( 69 ) is not a supported tag. - - Run with -h for help. - diff --git a/kazoj/kulpo/error_42 b/kazoj/kulpo/error_42 deleted file mode 100755 index e5c0302..0000000 --- a/kazoj/kulpo/error_42 +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./amboso -qTibprdgB manyflags_T diff --git a/kazoj/kulpo/error_42.k b/kazoj/kulpo/error_42.k new file mode 100755 index 0000000..aa65fb9 --- /dev/null +++ b/kazoj/kulpo/error_42.k @@ -0,0 +1,3 @@ +#!/bin/bash + +./amboso -PqTibprdgB manyflags_T diff --git a/kazoj/kulpo/error_42.k.stderr b/kazoj/kulpo/error_42.k.stderr new file mode 100644 index 0000000..7183854 --- /dev/null +++ b/kazoj/kulpo/error_42.k.stderr @@ -0,0 +1,6 @@ +[MODE] Running in test mode. +[DEBUG] No -D flag, using ( ./bin/ ) for target dir. Run with -V to see more. +[DEBUG] bone dir (NO -K passed to this call): ( bone ) +[DEBUG] kulpo dir (NO -K passed to this amboso call): ( kulpo ) +[PANIC] Running "amboso" using test mode in a program that will be called by test mode is not supported. + diff --git a/kazoj/kulpo/error_42.stdout b/kazoj/kulpo/error_42.k.stdout similarity index 100% rename from kazoj/kulpo/error_42.stdout rename to kazoj/kulpo/error_42.k.stdout diff --git a/kazoj/kulpo/error_42.stderr b/kazoj/kulpo/error_42.stderr deleted file mode 100644 index 244f472..0000000 --- a/kazoj/kulpo/error_42.stderr +++ /dev/null @@ -1,7 +0,0 @@ -[MODE] Running in test mode. -[DEBUG] No -D flag, using ( ./bin/ ) for target dir. Run with -V to see more. -[DEBUG] bone dir (NO -K passed to this call): ( bone ) - kulpo dir (NO -K passed to this amboso call): ( kulpo ) - -[PANIC] Running "amboso" using test mode in a program that will be called by test mode is not supported. - diff --git a/kazoj/kulpo/error_69 b/kazoj/kulpo/error_69 deleted file mode 100644 index ee89167..0000000 --- a/kazoj/kulpo/error_69 +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./amboso -qtibprdgB 0.1.0 diff --git a/kazoj/kulpo/error_69.k b/kazoj/kulpo/error_69.k new file mode 100644 index 0000000..8ce2962 --- /dev/null +++ b/kazoj/kulpo/error_69.k @@ -0,0 +1,3 @@ +#!/bin/bash + +./amboso -PqtibprdgB 0.1.0 diff --git a/try-anvil/try_anvil b/try-anvil/try_anvil index f18a9c0..f48e283 100755 --- a/try-anvil/try_anvil +++ b/try-anvil/try_anvil @@ -96,7 +96,7 @@ HINT " STEP 5/10 read