Skip to content
Snippets Groups Projects
Verified Commit 735fd25c authored by Karel Koci's avatar Karel Koci :metal: Committed by Karel Koci
Browse files

helpers/common: let user optionally decide if output is TTY

parent cd222783
2 merge requests!123Turris OS 5.0 (HBK),!96compile_pkgs: move print functions to separate file
......@@ -15,12 +15,19 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
## Common printing functions ############
# Detect tty if IS_TTY not already set
if [ -z "${IS_TTY+x}" ]; then
export IS_TTY=""
[ -t 2 ] && IS_TTY="1"
fi
_color_echo() {
local name="$1"
local color="$2"
local text="$3"
shift 2
if [ -t 2 ] || [ -n "$IS_TTY" ]; then
if [ -n "$IS_TTY" ]; then
echo -e "\033[${color}m${text}"'\033[0m' >&2
else
echo "$name: $text" >&2
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment