From c3fd07258874047e6f77a6653fc4de3a99bfc350 Mon Sep 17 00:00:00 2001 From: Paul Casto Date: Sat, 29 Aug 2026 17:33:39 -0700 Subject: [PATCH 1/3] prepended [Verbose] to vecho, and [Debug] to vvecho. Simplified logic used to debug a single special case, and removed decho --- abcde | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/abcde b/abcde index 031a261..082cb03 100755 --- a/abcde +++ b/abcde @@ -4077,7 +4077,7 @@ vecho () if [ x"$EXTRAVERBOSE" != "x" ] && [ "$EXTRAVERBOSE" -gt 0 ] ; then case $1 in warning) shift ; log warning "$@" ;; - *) >&4 echo "$@" ;; + *) >&4 echo "[Verbose] $@" ;; esac fi } @@ -4090,25 +4090,25 @@ vvecho () if [ x"$EXTRAVERBOSE" != "x" ] && [ "$EXTRAVERBOSE" -gt 1 ] ; then case $1 in warning) shift ; log warning "$@" ;; - *) >&4 echo "$@" ;; + *) >&4 echo "[Debug] $@" ;; esac fi } -# decho [message] +# decho [message] - removed in preference to vvecho. # # decho outputs a debug message if DEBUG is selected -decho () -{ -if [ x"$DEBUG" != "x" ]; then - if echo "$1" | grep "^\[" > /dev/null 2>&1 ; then - DEBUGECHO=$(echo "$@" | tr -d '[]') - echo >&4 "[DEBUG] $DEBUGECHO: $(eval echo \\$${DEBUGECHO})" - else - echo >&4 "[DEBUG] $1" - fi -fi -} +#decho () +#{ +#if [ x"$DEBUG" != "x" ]; then +# if echo "$1" | grep "^\[" > /dev/null 2>&1 ; then +# DEBUGECHO=$(echo "$@" | tr -d '[]') +# echo >&4 "[DEBUG] $DEBUGECHO: $(eval echo \\$${DEBUGECHO})" +# else +# echo >&4 "[DEBUG] $1" +# fi +#fi +#} # User-redefinable functions # Custom filename munging: @@ -4631,7 +4631,7 @@ while getopts 1a:bBc:C:d:DefgGhj:klLmMnNo:pPQ:r:s:S:t:T:UvVxX:w:W:z opt ; do STARTTRACKNUMBERTAG="y" vecho Comment is "${COMMENT}" >&2 ;; - z) DEBUG=y ; CDROMREADERSYNTAX=debug ; EJECTCD="n" ;; + z) CDROMREADERSYNTAX=debug ; EJECTCD="n" ;; ?) usage; exit ;; esac done @@ -5422,14 +5422,20 @@ if [ "$USEPIPES" = "y" ]; then aac) PIPEENCODERSVARCHECK="PIPE_$AACENCODERSYNTAX" ;; esac - decho "PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )" + # decho "PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )" + if CDROMREADERSYNTAX=debug; then + echo "[DEBUG] PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )" + fi if [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "$" ] || \ [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "" ] ; then log error "no support for pipes with given ripper" log error "read the FAQ file from the source tarball to get help." exit 1; fi - decho "PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )" + # decho "PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )" + if CDROMREADERSYNTAX=debug; then + echo "[DEBUG] PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )" + fi if [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "$" ] || \ [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "" ] ; then log error "no support for pipes with given encoder" From fa350cac37203f7d711f8b19437c14b3a7b217d1 Mon Sep 17 00:00:00 2001 From: Paul Casto Date: Sun, 30 Aug 2026 13:02:07 -0700 Subject: [PATCH 2/3] Changed vecho and vvecho to use -n for no newline and -c for continue on same line. This allows for more flexible output formatting. Found only one instance where vecho -n really should have suppressed the newline. The other three instances did not appear to need the newline suppression. Added a new directory for test-snippets which may prove useful for isolated testing of code. Log-testing.sh also includes a proposed change to allow for migration (gradual) from echo=>log. That change would be in a future pull request, if it makes sense to do so. It is not part of this pull request. --- abcde | 60 ++++++++++++++++----------------- test-snippets/README | 6 ++++ test-snippets/log-testing.sh | 64 ++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 30 deletions(-) create mode 100644 test-snippets/README create mode 100755 test-snippets/log-testing.sh diff --git a/abcde b/abcde index 082cb03..1378344 100755 --- a/abcde +++ b/abcde @@ -1497,8 +1497,8 @@ do_encode () esac ;; *) - vecho -n "DISTMP3:" - vecho "$DISTMP3 $DISTMP3OPTS $2 $IN $OUT >/dev/null 2>&1" + vecho -n "DISTMP3: " + vecho -c "$DISTMP3 $DISTMP3OPTS $2 $IN $OUT >/dev/null 2>&1" $RUN_COMMAND nice $DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" > /dev/null 2>&1 ;; esac @@ -2240,7 +2240,7 @@ do_discid () { SUBMITURL= if [ -z "${CDDBDISCID}" ]; then - vecho -n "Getting CD track info... " + vecho "Getting CD track info... " # In OSX, unmount the disc before a query if [ "$OSFLAVOUR" = "OSX" ]; then diskutil unmount "${CDROM#/dev/}" @@ -3120,7 +3120,7 @@ do_cddb_read () ;; 210|211) # Multiple exact, (possibly multiple) inexact matches - vecho -n "Retrieving multiple matches... " + vecho "Retrieving multiple matches... " grep -v '^[.]$' "${SOURCE_WORKDIR}/cddbquery" | ( # IN A SUB-SHELL - VARIABLES MODIFIED # HERE DO NOT PERSIST IN THE PARENT @@ -4069,46 +4069,52 @@ do_cdspeed () fi } -# vecho [message] +# vecho [-c|-n] [message] # # vecho outputs a message if EXTRAVERBOSE is 1 or more +# -c is for a continuation line, -n is for no newline vecho () { if [ x"$EXTRAVERBOSE" != "x" ] && [ "$EXTRAVERBOSE" -gt 0 ] ; then case $1 in warning) shift ; log warning "$@" ;; - *) >&4 echo "[Verbose] $@" ;; + -c) shift ; >&4 echo "$@" ;; # for a continuation line + -n) shift ; >&4 echo -n "[Verbose] $@" ;; + *) >&4 echo "[Verbose] $@" ;; esac fi } -# vvecho [message] +# vvecho [-c|-n] [message] # # vvecho outputs a message if EXTRAVERBOSE is 2 or more +# -c is for a continuation line, -n is for no newline vvecho () { if [ x"$EXTRAVERBOSE" != "x" ] && [ "$EXTRAVERBOSE" -gt 1 ] ; then case $1 in warning) shift ; log warning "$@" ;; - *) >&4 echo "[Debug] $@" ;; + -c) shift ; >&4 echo "$@" ;; # for a continuation line + -n) shift ; >&4 echo -n "[Verbose2] $@" ;; + *) >&4 echo "[Verbose2] $@" ;; esac fi } -# decho [message] - removed in preference to vvecho. +# decho [message] # # decho outputs a debug message if DEBUG is selected -#decho () -#{ -#if [ x"$DEBUG" != "x" ]; then -# if echo "$1" | grep "^\[" > /dev/null 2>&1 ; then -# DEBUGECHO=$(echo "$@" | tr -d '[]') -# echo >&4 "[DEBUG] $DEBUGECHO: $(eval echo \\$${DEBUGECHO})" -# else -# echo >&4 "[DEBUG] $1" -# fi -#fi -#} +decho () +{ +if [ x"$DEBUG" != "x" ]; then + if echo "$1" | grep "^\[" > /dev/null 2>&1 ; then + DEBUGECHO=$(echo "$@" | tr -d '[]') + echo >&4 "[DEBUG] $DEBUGECHO: $(eval echo \\$${DEBUGECHO})" + else + echo >&4 "[DEBUG] $1" + fi +fi +} # User-redefinable functions # Custom filename munging: @@ -4631,7 +4637,7 @@ while getopts 1a:bBc:C:d:DefgGhj:klLmMnNo:pPQ:r:s:S:t:T:UvVxX:w:W:z opt ; do STARTTRACKNUMBERTAG="y" vecho Comment is "${COMMENT}" >&2 ;; - z) CDROMREADERSYNTAX=debug ; EJECTCD="n" ;; + z) DEBUG=y ; CDROMREADERSYNTAX=debug ; EJECTCD="n" ;; ?) usage; exit ;; esac done @@ -5422,20 +5428,14 @@ if [ "$USEPIPES" = "y" ]; then aac) PIPEENCODERSVARCHECK="PIPE_$AACENCODERSYNTAX" ;; esac - # decho "PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )" - if CDROMREADERSYNTAX=debug; then - echo "[DEBUG] PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )" - fi + decho "PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )" if [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "$" ] || \ [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "" ] ; then log error "no support for pipes with given ripper" log error "read the FAQ file from the source tarball to get help." exit 1; fi - # decho "PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )" - if CDROMREADERSYNTAX=debug; then - echo "[DEBUG] PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )" - fi + decho "PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )" if [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "$" ] || \ [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "" ] ; then log error "no support for pipes with given encoder" @@ -5525,7 +5525,7 @@ if [ "$DOREAD" = "y" ]; then # User-definable function to set some things. Use it for # - closing the CD tray with eject -t # - set the CD speed value with eject -x - vecho -n "Executing customizable pre-read function... " + vecho "Executing customizable pre-read function... " pre_read # Execute the user-defined pre-read function. Close the CD with it. diff --git a/test-snippets/README b/test-snippets/README new file mode 100644 index 0000000..138f812 --- /dev/null +++ b/test-snippets/README @@ -0,0 +1,6 @@ +Directory for test code snippets + +Allows for testing individual functions, +without having to fully invoke abcde. + +Not needed/wanted as part of deployment. \ No newline at end of file diff --git a/test-snippets/log-testing.sh b/test-snippets/log-testing.sh new file mode 100755 index 0000000..7d659c6 --- /dev/null +++ b/test-snippets/log-testing.sh @@ -0,0 +1,64 @@ +#! /opt/homebrew/bin/bash + +# log [level] [message] +# +# log outputs the right message in a common format +log () +{ + BLURB="$1" + shift + case $BLURB in + error) >&2 echo "[ERROR] abcde: $@" >&2 ;; + warning) >&2 echo "[WARNING] $@" >&2 ;; + info) >&4 echo "[INFO] $@" ;; + console) >&4 echo "$@" ;; + esac +} + +# vecho [-c|-n] [message] +# +# vecho outputs a message if EXTRAVERBOSE is 1 or more +# -c is for a continuation line, -n is for no newline +vecho () +{ +if [ x"$EXTRAVERBOSE" != "x" ] && [ "$EXTRAVERBOSE" -gt 0 ] ; then + case $1 in + warning) shift ; log warning "$@" ;; + -c) shift ; >&4 echo "$@" ;; # for a continuation line + -n) shift ; >&4 echo -n "[Verbose] $@" ;; + *) >&4 echo "[Verbose] $@" ;; + esac +fi +} + +# vvecho [-c|-n] [message] +# +# vvecho outputs a message if EXTRAVERBOSE is 2 or more +# -c is for a continuation line, -n is for no newline +vvecho () +{ +if [ x"$EXTRAVERBOSE" != "x" ] && [ "$EXTRAVERBOSE" -gt 1 ] ; then + case $1 in + warning) shift ; log warning "$@" ;; + -c) shift ; >&4 echo "$@" ;; # for a continuation line + -n) shift ; >&4 echo -n "[Verbose2] $@" ;; + *) >&4 echo "[Verbose2] $@" ;; + esac +fi +} + +exec 4>&1 +EXTRAVERBOSE=$1 + +echo "testing vecho and vvecho functions" +log console "call with a number 1 or 2 to see verbose logging output" +vecho "with newline" +vecho -n "without newline: " +vecho -c "continued on the same line" + +vvecho "with newline" +vvecho -n "without newline: " +vvecho -c "continued on the same line" + +log console "testing console log -- print without prefix" +log info "testing info log -- print with [INFO] prefix" From 1b00d6226a98062d336405ccbb9f094fa555e563 Mon Sep 17 00:00:00 2001 From: Paul Casto Date: Sun, 30 Aug 2026 13:40:44 -0700 Subject: [PATCH 3/3] removed mac-ism... --- test-snippets/log-testing.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-snippets/log-testing.sh b/test-snippets/log-testing.sh index 7d659c6..9452184 100755 --- a/test-snippets/log-testing.sh +++ b/test-snippets/log-testing.sh @@ -1,4 +1,4 @@ -#! /opt/homebrew/bin/bash +#! /bin/bash # log [level] [message] #