Re: Disabling/Enabling Keys in BASH Script
From: Icarus Sparry (usenet_at_icarus.freeuk.com)
Date: 06/13/04
- Next message: Icarus Sparry: "Re: ENV and non-login process"
- Previous message: Icarus Sparry: "Re: Proposal for 'touch -x'"
- In reply to: Dr. Lince M. Lawrence: "Re: Disabling/Enabling Keys in BASH Script"
- Next in thread: Bob: "Re: Disabling/Enabling Keys in BASH Script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 13 Jun 2004 00:20:18 GMT
On Fri, 11 Jun 2004 23:30:12 -0700, Dr. Lince M. Lawrence wrote:
> I want to run a function, say help, in my script at any time the user
> wants. Pressing a key (CTRL+ALT+F) should enable this function like
> pressing the key CTRL+C to quit.
Not easy to do in the general case. The characters (if any) returned by
different terminals in response to function keys vary a lot. It is more
portable to make a shell function to print a question, read an input line,
if the line is just "?" or "help" then display some help and re-prompt
with the question.
The way that CTRL-C works is not very flexible, and would only work if
your CTRL-ALT-F returned a single character.
Other things you can look at include using 'expect', and in particular the
"interact" command. Your program could look like
#!/usr/bin/expect
spawn real_program
interact "characters sent by CTRL-ALT-F" {puts "Here is some help"}
If you are running in an X display, you may be able to get your window
manager to intercept the CTRL-ALT-F key, and pop up another window with
some help in it.
Icarus
- Next message: Icarus Sparry: "Re: ENV and non-login process"
- Previous message: Icarus Sparry: "Re: Proposal for 'touch -x'"
- In reply to: Dr. Lince M. Lawrence: "Re: Disabling/Enabling Keys in BASH Script"
- Next in thread: Bob: "Re: Disabling/Enabling Keys in BASH Script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|