Article View: gnu.bash.bug
Article #598Bash-1.03 and exported PATH and history substitutions
From: Brian Fox
Date: Fri, 15 Sep 1989 16:11
Date: Fri, 15 Sep 1989 16:11
151 lines
4468 bytes
4468 bytes
Whoops, I forgot the patches...
----------------------------------------
File: /usr/gnu/src/lib/readline/history-diffs
----------------------------------------
*** history.c.~10~ Thu Aug 31 14:10:07 1989
--- history.c Fri Sep 15 08:53:04 1989
***************
*** 661,667 ****
int i, word_spec_error = 0;
int cc, modified = 0;
char *word_spec, *event;
! int starting_index, only_printing = 0;
char *get_history_word_specifier (), *rindex ();
--- 661,667 ----
int i, word_spec_error = 0;
int cc, modified = 0;
char *word_spec, *event;
! int starting_index, only_printing = 0, substitute_globally = 0;
char *get_history_word_specifier (), *rindex ();
***************
*** 696,701 ****
--- 696,702 ----
history_expansion_char, history_expansion_char,
string);
string = format_string;
+ l += 4;
goto grovel;
}
***************
*** 853,866 ****
goto next_special;
/* :s/this/that substitutes `this' for `that'. */
case 's':
{
char *this, *that, *new_event;
! int delimiter = string[i + 2];
int si, l_this, l_that, l_temp = strlen (temp);
! if (!delimiter) break;
i += 3;
/* Get THIS. */
--- 854,882 ----
goto next_special;
/* :s/this/that substitutes `this' for `that'. */
+ /* :gs/this/that substitutes `this' for `that' globally. */
+ case 'g':
+ if (string[i + 2] == 's')
+ {
+ i++;
+ substitute_globally = 1;
+ goto substitute;
+ }
+ else
+
case 's':
+ substitute:
{
char *this, *that, *new_event;
! int delimiter = 0;
int si, l_this, l_that, l_temp = strlen (temp);
! if (i + 2 < strlen (string))
! delimiter = string[i + 2];
+ if (!delimiter)
+ break;
+
i += 3;
/* Get THIS. */
***************
*** 889,912 ****
goto cant_substitute;
/* Find the first occurrence of THIS in TEMP. */
! for (si = 0; (si + l_this) <= l_temp; si++)
! if (strncmp (temp + si, this, l_this) == 0) {
! new_event =
! (char *)alloca (1 + (l_that - l_this) + l_temp);
! strncpy (new_event, temp, si);
! strncpy (new_event + si, that, l_that);
! strncpy (new_event + si + l_that,
! temp + si + l_this,
! l_temp - (si + l_this));
! new_event[(l_that - l_this) + l_temp] = '\0';
! temp = new_event;
goto hack_specials;
}
- cant_substitute:
goto event_not_found;
}
-
/* :# is the line so far. Note that we have to
alloca () it since RESULT could be realloc ()'ed
--- 905,945 ----
goto cant_substitute;
/* Find the first occurrence of THIS in TEMP. */
! si = 0;
! for (; (si + l_this) <= l_temp; si++)
! if (strncmp (temp + si, this, l_this) == 0)
! {
! new_event =
! (char *)alloca (1 + (l_that - l_this) + l_temp);
! strncpy (new_event, temp, si);
! strncpy (new_event + si, that, l_that);
! strncpy (new_event + si + l_that,
! temp + si + l_this,
! l_temp - (si + l_this));
! new_event[(l_that - l_this) + l_temp] = '\0';
! temp = new_event;
!
! if (substitute_globally)
! {
! si += l_that;
! l_temp = strlen (temp);
! substitute_globally++;
! continue;
! }
!
! goto hack_specials;
! }
!
! cant_substitute:
!
! if (substitute_globally > 1)
! {
! substitute_globally = 0;
goto hack_specials;
}
goto event_not_found;
}
/* :# is the line so far. Note that we have to
alloca () it since RESULT could be realloc ()'ed
----------------------------------------
Technical Details
Message-ID:
<8909151611.AA26713@aurel.caltech.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfoxReferences:
<8909140905.AA04621@baby.bby.oz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfox From: bfox@AUREL.CALTECH.EDU (Brian Fox) Newsgroups: gnu.bash.bug Subject: Bash-1.03 and exported PATH and history substitutions Message-ID: <8909151611.AA26713@aurel.caltech.edu> Date: 15 Sep 89 16:11:44 GMT References: <8909140905.AA04621@baby.bby.oz> Sender: daemon@tut.cis.ohio-state.edu Reply-To: bfox@aurel.caltech.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 151