Article View: gnu.bash.bug
Article #72Prompt interpretation for bash
From: James Van Artsdalen
Date: Tue, 13 Jun 1989 18:13
Date: Tue, 13 Jun 1989 18:13
40 lines
1590 bytes
1590 bytes
Here's an attempt to get bash to interpret prompt strings like ksh
does. I don't the code all that well yet, hence the use of alloca to
protect against memory leakage through longjmp().
If all of the magic \ characters available to PS1 were made accessible
shell variables (so shell scripts could use them too), you'd have a
completely general solution. PROMPT_COMMAND is merely a special case
of this scheme, as in
PS1='`$PROMPT_COMMAND`rest_of_prompt'
***************
*** 472,479 ****
{
char *readline_internal ();
char *value;
! rl_prompt = prompt;
/* If we are at EOF that is what we return. */
if (rl_pending_input == EOF) {
--- 481,494 ----
{
char *readline_internal ();
char *value;
+ WORD_LIST *wp;
+ WORD_DESC word;
! word.word = prompt;
! wp = expand_word(&word, 1);
! rl_prompt = alloca(strlen(wp->word->word));
! strcpy(rl_prompt, wp->word->word);
! dispose_words(wp);
/* If we are at EOF that is what we return. */
if (rl_pending_input == EOF) {
--
James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die"
Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789
Technical Details
Message-ID:
<18027@bigtex.cactus.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!milano!bigtex!jamesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!milano!bigtex!james From: james@bigtex.cactus.org (James Van Artsdalen) Newsgroups: gnu.bash.bug Subject: Prompt interpretation for bash Message-ID: <18027@bigtex.cactus.org> Date: 13 Jun 89 18:13:53 GMT Organization: Institute of Applied Cosmology, Austin TX Lines: 40