fixing_init.d_scripts_for_emacs_subshells

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: the init.d blahs: ^[[60G[  ^[[1;32mIS REALLY NOT OK^[[0;39m  ]
From: Joe Brenner <doom@kzsu.stanford.edu>
Date: Thu, 21 Sep 2000 20:24:20 -0700

I'm answering my own question here, just for the
record... 

Okay, so since I've been tweaking my httpd.conf a lot
lately, I get to do things like this a lot: 

   su 
   /etc/rc.d/init.d/httpd restart

And since I live inside emacs, I do this inside an emacs
subshell, where I constantly get treated to displays like
this, littered with ansi control sequences: 

   Shutting down http: ^[[60G[  ^[[1;32mOK^[[0;39m  ]
   Starting httpd: ^[[60G[  ^[[1;32mOK^[[0;39m  ]

These are of course supposed to be putting pretty colors on
the screen to make it easier for me to read the word "OK" 
or "FAILED", but instead they do a good job of concealing
the result completely. 

I tried a few ways of fixing this obnoxious behavior, but
the following is what worked.

After some blundering around I noticed that there was an if
block in:

  /etc/rc.d/init.d/functions

that removed the ansi sequences for consoles of type
"serial".  I ran /sbin/consoletype in an emacs sub-shell, 
and discovered that it was type "pty".  

So as a quick fix, I just cloned the entire if block, and
changed the "serial" to "pty":

    if [ "`consoletype`" = "pty" ]; then
      BOOTUP=serial
      MOVE_TO_COL=
      SETCOLOR_SUCCESS=
      SETCOLOR_FAILURE=
      SETCOLOR_WARNING=
      SETCOLOR_NORMAL=
    fi


If someone wants to point out that I could've done an OR and
just made the test a litte more complex, I will not argue.
I haven't been Bourne shelling much of late and did not feel
like looking up the syntax.


===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu