EINFO(3)
π EINFO(3) β colorful informational output π
Hiii bestie, welcome to the einfo family, a whole little library of functions living in libeinfo (link it with -leinfo) that make your program print cute lil' colored lines instead of boring gray ones. It's giving terminal glow-up, and honestly? Iconic. β¨
π NAME π
einfo, ewarn, eerror, ebegin, einfon, ewarnn, eerrorn, ebeginn, einfov, ewarnv, ebeginv, einfovn, ewarnvn, ebeginvn, ewarnx, eerrorx, eend, ewend, eendv, ewendv, ebracket, eindent, eoutdent, eindentv, eoutdentv, eprefix β colorful informational output π¦
π LIBRARY π
Enhanced Information output library (libeinfo, -leinfo) π
β¨ SYNOPSIS β¨
#include <einfo.h>
int
einfo(const char * restrict format, ...);
int
ewarn(const char * restrict format, ...);
int
eerror(const char * restrict format, ...);
int
ebegin(const char * restrict format, ...);
int
einfon(const char * restrict format, ...);
int
ewarnn(const char * restrict format, ...);
int
eerrorn(const char * restrict format, ...);
int
ebeginn(const char * restrict format, ...);
int
einfov(const char * restrict format, ...);
int
ewarnv(const char * restrict format, ...);
int
ebeginv(const char * restrict format, ...);
int
einfovn(const char * restrict format, ...);
int
ewarnvn(const char * restrict format, ...);
int
ebeginvn(const char * restrict format, ...);
int
ewarnx(const char * restrict format, ...);
int
eerrorx(const char * restrict format, ...);
int
eend(int retval, const char * restrict format, ...);
int
ewend(int retval, const char * restrict format, ...);
int
eendv(int retval, const char * restrict format, ...);
int
ewendv(int retval, const char * restrict format, ...);
void
ebracket(int col, ECOLOR color, const char * restrict msg);
void
eindent(void);
void
eoutdent(void);
void
eindentv(void);
void
eoutdentv(void);
void
eprefix(const char * prefix);
π«Ά DESCRIPTION π«Ά
Okay so the einfo() family gives you simple informational output, but colorised. Basically einfo(), ewarn(), and eerror() behave exactly like printf() β except they slap a colored * at the front of your output. And the function you call decides the color, no cap:
einfo()β green πewarn()β yellow πeerror()β red β€οΈ
Also, einfo goes to stdout, and the other two go to stderr (classy). The return value is the number of real characters printed. And ebegin() is literally identical to einfo() except it appends 3 dots to the output β like it's leaving the group chat with a "...". π
einfov(), ewarnv(), and ebeginv() work the same way as einfo(), ewarn(), and ebegin() respectively, but they only actually do anything when EINFO_VERBOSE is true. Meanwhile you can make einfo(), ewarn(), and ebegin() go totally silent by setting EINFO_QUIET to true. Nothing printed. Muted. On read. π
So these functions were designed to output a whole line, which is why they also append a newline to the string. If you don't want that behavior, use einfon(), ewarnn(), eerrorn(), einfovn(), ewarnvn(), or ebeginvn() instead. The n means "no newline," iykyk. π§
Now the finale functions β eend(), ewend(), eendv(), and ewendv() are the counterparts to all of the above. Here's the vibe check:
- If
retvalis zero, thenokin green gets printed in a bracket at the end of the prior line. π - Otherwise, the formatted string gets printed using
error()(orewarn()if you calledewend()), and!!in red (or yellow if you calledewend()) gets printed in a bracket at the end of the line. - Either way, the value of
retvalis returned.
ebracket() does the same thing as eend() but prints msg instead of ok or !!, in the color color, at the column col. Custom bracket moment. π
eindent() indents subsequent calls to all of the above functions by 2 characters. eoutdent() removes an eindent(). And eindentv() / eoutdentv() only work when EINFO_VERBOSE is true. πΈ
eprefix() prefixes the string prefix to the above functions. Put a lil' label on everything. π·οΈ
π± ENVIRONMENT π±
EINFO_QUIETβ when set to true, makes theeinfo()andeinfon()family of functions quiet, so nothing is printed. π€«EERROR_QUIETβ when set to true, makes theeerror()andeerrorn()family of functions quiet, so nothing is printed. π€EINFO_VERBOSEβ when set to true, makes theeinfov()andeinfovn()family of functions work, so they do print. π£
π FILES π
/etc/init.d/functions.shβ provided by OpenRC, which lets shell scripts use all of the above functions. π
Heads up bestie, historical reasons incoming: our verbose functions are prefixed withvinstead of suffixed. Soeinfovbecomesveinfo, andeinfovnbecomesveinfon. Rinse and repeat for the other verbose functions. It's giving old money naming conventions, but we respect the lore. π
π SEE ALSO π
π AUTHORS π
Roy Marples <roy@marples.name>
That's the whole page, bestie β go forth and print in color, you absolute icon. π
This lil' number comes from OpenRC, dated Mar 16, 2008 β yeah, she's been slaying since the 2000s and she's still serving. Periodt. π
π¦ where this page comes from
- alpine 3.23: openrc-doc 0.63-r1 Β· BSD-2-Clause
- alpine 3.24: openrc-doc 0.63.2-r0 Β· BSD-2-Clause
- Copyright (c) 2007-2025 The OpenRC Authors
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms