From: Bartosz Fenski Subject: If running inside Emacs M-x shell, turn of colors by default --- a/ipcalc +++ b/ipcalc @@ -708,7 +708,13 @@ sub getopts if (-t STDOUT) { $opt_color = 1; } - + + # Under Emacs, do not use colors by default. The TERM is for older + # Emacs versions. + if ( !defined($ENV{'TERM'}) or $ENV{'TERM'} =~ /dumb/i or $ENV{'INSIDE_EMACS'} ) { + $opt_color = 0; + } + while (has_opts()) { $arg = shift @ARGV; if ($arg =~ /^--(.+)/) { @@ -781,6 +787,9 @@ sub getopts elsif ($opt eq 'help') { $opt_help = 1; } + elsif ($opt eq 'c' || $opt eq 'color') { + $opt_color = 1; + } elsif ($opt eq 'n' || $opt eq 'nocolor') { $opt_color = 0; } @@ -1047,6 +1056,7 @@ can design sub- and supernetworks. It is also intended to be a teaching tool and presents the results as easy-to-understand binary values. -n --nocolor Don't display ANSI color codes. + -c --color Display ANSI color codes (default). -b --nobinary Suppress the bitwise output. -c --class Just print bit-count-mask of given address. -h --html Display results as HTML (not finished in this version). --