[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] read -ep and ANSI colour sequences

From: Greg Wooledge
Subject: Re: [Help-bash] read -ep and ANSI colour sequences
Date: Wed, 20 Feb 2013 08:51:14 -0500
User-agent: Mutt/

On Wed, Feb 20, 2013 at 02:06:41PM +0100, muji wrote:
> The use case is an interactive shell program. FYI, I am using bash-4.2.

Stop trying to write a shell in shell script.  It's ludicrous.  Bash
is simply not a powerful enough language for this job.

If you need the kind of direct control over the terminal that you
claim you need, then you should be writing in C with a curses library
(or slang, or whatever people use for terminal control these days).
You can link in the readline library if you want, though I don't know
how well readline interacts with curses/slang/whatever you are using
to send color codes and keep track of the position of the cursor.  You
may even have to write your own readline replacement for this job.

Or, the simpler approach would be to re-specify the problem so that you
do not need color escape sequences in your prompts.

And whatever you do, STOP hard-coding terminal-specific escape sequences.
This will cease working when you run it on a terminal that uses different
escape sequences.  This is why we have termcap/terminfo libraries and
a $TERM variable.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]