Stop blindly assuming that a blank TERM is cons25. For cons25 terms we drop one column so we don't get an extra newline.
This commit is contained in:
parent
b2d024b7f4
commit
700bdb4f1d
@ -5,10 +5,13 @@
|
||||
# Ensure we are called by init
|
||||
[ "$PPID" = "1" ] || exit 0
|
||||
|
||||
# If $TERM is not set then assume default of cons25
|
||||
# This gives us a nice colour boot :)
|
||||
[ -z "$TERM" ] && export TERM="cons25"
|
||||
|
||||
# BSD's init works somewhat differently to sysvinit.
|
||||
# This block should 'translate' from the way init calls it to the way it would
|
||||
# be called by sysvinit on linux.
|
||||
|
||||
RUNLEVEL="1" /sbin/rc sysinit || exit 1
|
||||
RUNLEVEL="1" /sbin/rc boot || exit 1
|
||||
PREVLEVEL="1" /sbin/rc default
|
||||
|
@ -7,8 +7,11 @@
|
||||
|
||||
# Try and use stuff in /lib over anywhere else so we can shutdown
|
||||
# local mounts correctly.
|
||||
LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}"
|
||||
export LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}"
|
||||
|
||||
# If $TERM is not set then assume default of cons25
|
||||
# This gives us a nice colour shutdown :)
|
||||
[ -z "$TERM" ] && export TERM="cons25"
|
||||
|
||||
# BSD's init works somewhat differently to sysvinit.
|
||||
# This block should 'translate' from the way init calls it to the way it would
|
||||
|
@ -124,6 +124,8 @@ static const char *color_terms[] = {
|
||||
static int stdfd[2] = {-1, -1};
|
||||
static FILE *ebfp = NULL;
|
||||
static char ebfile[PATH_MAX] = { '\0' };
|
||||
static const char *term = NULL;
|
||||
static bool term_is_cons25 = false;
|
||||
|
||||
/* A pointer to a string to prefix to einfo/ewarn/eerror messages */
|
||||
static const char *_eprefix = NULL;
|
||||
@ -146,17 +148,22 @@ static bool colour_terminal (void)
|
||||
{
|
||||
static int in_colour = -1;
|
||||
int i = 0;
|
||||
char *term;
|
||||
|
||||
if (in_colour == 0)
|
||||
return (false);
|
||||
if (in_colour == 1)
|
||||
return (true);
|
||||
|
||||
if (! term) {
|
||||
term = getenv ("TERM");
|
||||
/* If $TERM isn't set then the chances are we're in single user mode */
|
||||
if (! term)
|
||||
return (true);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (strcmp (term, "cons25") == 0)
|
||||
term_is_cons25 = true;
|
||||
else
|
||||
term_is_cons25 = false;
|
||||
|
||||
while (color_terms[i]) {
|
||||
if (strcmp (color_terms[i], term) == 0) {
|
||||
@ -575,26 +582,35 @@ int ebegin (const char *fmt, ...)
|
||||
}
|
||||
hidden_def(ebegin)
|
||||
|
||||
static void _eend (int col, einfo_color_t color, const char *msg)
|
||||
static void _eend (FILE *fp, int col, einfo_color_t color, const char *msg)
|
||||
{
|
||||
FILE *fp = stdout;
|
||||
int i;
|
||||
int cols;
|
||||
|
||||
if (! msg)
|
||||
return;
|
||||
|
||||
if (color == ecolor_bad)
|
||||
fp = stderr;
|
||||
cols = get_term_columns () - (strlen (msg) + 5);
|
||||
|
||||
cols = get_term_columns () - (strlen (msg) + 6);
|
||||
/* cons25 is special - we need to remove one char, otherwise things
|
||||
* do not align properly at all. */
|
||||
if (! term) {
|
||||
term = getenv ("TERM");
|
||||
if (term && strcmp (term, "cons25") == 0)
|
||||
term_is_cons25 = true;
|
||||
else
|
||||
term_is_cons25 = false;
|
||||
}
|
||||
if (term_is_cons25)
|
||||
cols--;
|
||||
|
||||
if (cols > 0 && colour_terminal ()) {
|
||||
fprintf (fp, "\033[A\033[%dC %s[ %s%s %s]%s\n", cols,
|
||||
ecolor (ecolor_bracket), ecolor (color), msg,
|
||||
ecolor (ecolor_bracket), ecolor (ecolor_normal));
|
||||
} else {
|
||||
for (i = -1; i < cols - col; i++)
|
||||
if (col > 0)
|
||||
for (i = 0; i < cols - col; i++)
|
||||
fprintf (fp, " ");
|
||||
fprintf (fp, " [ %s ]\n", msg);
|
||||
}
|
||||
@ -603,7 +619,7 @@ static void _eend (int col, einfo_color_t color, const char *msg)
|
||||
static int _do_eend (const char *cmd, int retval, const char *fmt, va_list ap)
|
||||
{
|
||||
int col = 0;
|
||||
FILE *fp;
|
||||
FILE *fp = stdout;
|
||||
va_list apc;
|
||||
|
||||
if (fmt && retval != 0) {
|
||||
@ -616,11 +632,9 @@ static int _do_eend (const char *cmd, int retval, const char *fmt, va_list ap)
|
||||
fp = stderr;
|
||||
}
|
||||
va_end (apc);
|
||||
if (colour_terminal ())
|
||||
fprintf (fp, "\n");
|
||||
}
|
||||
|
||||
_eend (col,
|
||||
_eend (fp, col,
|
||||
retval == 0 ? ecolor_good : ecolor_bad,
|
||||
retval == 0 ? OK : NOT_OK);
|
||||
return (retval);
|
||||
@ -658,7 +672,7 @@ hidden_def(ewend)
|
||||
|
||||
void ebracket (int col, einfo_color_t color, const char *msg)
|
||||
{
|
||||
_eend (col, color, msg);
|
||||
_eend (stdout, col, color, msg);
|
||||
}
|
||||
hidden_def(ebracket)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user