live-build/functions/echo.sh

91 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2007-09-23 08:04:49 +00:00
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2016-2020 The Debian Live team
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
exec 3>&1
2007-09-23 08:04:49 +00:00
2008-08-14 18:25:29 +00:00
Echo ()
{
local STRING="${1}"
2008-08-14 18:25:29 +00:00
shift
printf "${STRING}\n" "${@}" >&3
2008-08-14 18:25:29 +00:00
}
2007-09-23 08:04:49 +00:00
Echo_debug ()
{
2020-03-01 02:49:57 -01:00
if [ "${_DEBUG}" = "true" ]; then
local STRING="${1}"
shift
printf "D: ${STRING}\n" "${@}" >&3
2007-09-23 08:04:49 +00:00
fi
}
Echo_error ()
{
local STRING="${1}"
shift
2007-09-23 08:04:51 +00:00
2020-03-01 02:49:57 -01:00
local PREFIX="${RED}E${NO_COLOR}"
if [ "${_COLOR_ERR}" = "false" ]; then
2020-03-01 02:49:57 -01:00
PREFIX="E"
fi
2020-03-01 02:49:57 -01:00
printf "${PREFIX}: ${STRING}\n" "${@}" >&2
2007-09-23 08:04:49 +00:00
}
Echo_message ()
{
if [ "${_QUIET}" != "true" ]
then
local STRING="${1}"
shift
2007-09-23 08:04:51 +00:00
local PREFIX="${PURPLE}P${NO_COLOR}"
if [ "${_COLOR_OUT}" = "false" ]; then
2020-03-01 02:49:57 -01:00
PREFIX="P"
fi
printf "${PREFIX}: ${STRING}\n" "${@}" >&3
fi
}
2007-09-23 08:04:49 +00:00
Echo_verbose ()
{
2020-03-01 02:49:57 -01:00
if [ "${_VERBOSE}" = "true" ]; then
local STRING="${1}"
shift
printf "I: ${STRING}\n" "${@}" >&3
2007-09-23 08:04:49 +00:00
fi
}
Echo_warning ()
{
local STRING="${1}"
shift
2007-09-23 08:04:51 +00:00
2020-03-01 02:49:57 -01:00
local PREFIX="${YELLOW}W${NO_COLOR}"
if [ "${_COLOR_ERR}" = "false" ]; then
2020-03-01 02:49:57 -01:00
PREFIX="W"
fi
2020-03-01 02:49:57 -01:00
printf "${PREFIX}: ${STRING}\n" "${@}" >&2
2007-09-23 08:04:49 +00:00
}
Echo_file ()
{
local LINE
while read -r LINE
do
echo "${1}: ${LINE}" >&3
done < "${1}"
}