Thread View: gnu.bash.bug
2 messages
2 total messages
Started by James Van Artsdalen
Tue, 13 Jun 1989 18:13
Prompt interpretation for bash
Author: 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
Prompt interpretation for bash
Author: composer
Date: Tue, 13 Jun 1989 22:21
Date: Tue, 13 Jun 1989 22:21
31 lines
1637 bytes
1637 bytes
| Date: 13 Jun 89 18:13:53 GMT | From: milano!bigtex!james@cs.utexas.edu (James Van Artsdalen) | | 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' I'm not that familiar with ksh specifics, so I'm not sure what you're referring to. But, I'm able to get the same thing to work as what I believe you want the above to do. PS1="`$PROMPT_COMMAND`rest_of_prompt" The double quotes will allow the $variable to be expanded. Is this what you were referring to? | James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die" | Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789 -jeff Jeff Kellem INTERNET: composer@bu-cs.bu.edu (or composer%bu-cs.bu.edu@bu-it.bu.edu) UUCP: ...!harvard!bu-cs!composer
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads