Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions abcde
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -4069,28 +4069,34 @@ 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 "$@" ;;
-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 "$@" ;;
-c) shift ; >&4 echo "$@" ;; # for a continuation line
-n) shift ; >&4 echo -n "[Verbose2] $@" ;;
*) >&4 echo "[Verbose2] $@" ;;
esac
fi
}
Expand Down Expand Up @@ -5519,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.

Expand Down
6 changes: 6 additions & 0 deletions test-snippets/README
Original file line number Diff line number Diff line change
@@ -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.
64 changes: 64 additions & 0 deletions test-snippets/log-testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#! /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"