Imported from ../bash-2.04.tar.gz.
This commit is contained in:
parent
b72432fdcc
commit
bb70624e96
387 changed files with 28522 additions and 9334 deletions
75
bashhist.c
75
bashhist.c
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
|
@ -408,7 +408,7 @@ pre_process_line (line, print_changes, addit)
|
|||
if (expanded < 0)
|
||||
internal_error ("%s", history_value);
|
||||
#if defined (READLINE)
|
||||
else if (hist_verify == 0)
|
||||
else if (hist_verify == 0 || expanded == 2)
|
||||
#else
|
||||
else
|
||||
#endif
|
||||
|
|
@ -457,6 +457,34 @@ pre_process_line (line, print_changes, addit)
|
|||
return (return_value);
|
||||
}
|
||||
|
||||
/* Return 1 if the first non-whitespace character in LINE is a `#', indicating
|
||||
* that the line is a shell comment. */
|
||||
static int
|
||||
shell_comment (line)
|
||||
char *line;
|
||||
{
|
||||
char *p;
|
||||
|
||||
for (p = line; p && *p && whitespace (*p); p++)
|
||||
;
|
||||
return (p && *p == '#');
|
||||
}
|
||||
|
||||
/* Remove shell comments from LINE. A `#' and anything after it is a comment.
|
||||
This isn't really useful yet, since it doesn't handle quoting. */
|
||||
static char *
|
||||
filter_comments (line)
|
||||
char *line;
|
||||
{
|
||||
char *p;
|
||||
|
||||
for (p = line; p && *p && *p != '#'; p++)
|
||||
;
|
||||
if (p && *p == '#')
|
||||
*p = '\0';
|
||||
return (line);
|
||||
}
|
||||
|
||||
/* Add LINE to the history list depending on the value of HISTORY_CONTROL. */
|
||||
void
|
||||
maybe_add_history (line)
|
||||
|
|
@ -476,7 +504,8 @@ maybe_add_history (line)
|
|||
if (current_command_line_count > 1)
|
||||
#endif
|
||||
{
|
||||
bash_add_history (line);
|
||||
if (literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0)
|
||||
bash_add_history (line);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -637,51 +666,15 @@ expand_histignore_pattern (pat)
|
|||
char *pat;
|
||||
{
|
||||
HIST_ENTRY *phe;
|
||||
char *ret, *p, *r, *t;
|
||||
int len, rlen, ind, tlen;
|
||||
char *ret;
|
||||
|
||||
phe = last_history_entry ();
|
||||
|
||||
if (phe == (HIST_ENTRY *)0)
|
||||
return (savestring (pat));
|
||||
|
||||
len = strlen (phe->line);
|
||||
rlen = len + strlen (pat) + 2;
|
||||
ret = xmalloc (rlen);
|
||||
ret = strcreplace (pat, '&', phe->line, 1);
|
||||
|
||||
for (p = pat, r = ret; p && *p; )
|
||||
{
|
||||
if (*p == '&')
|
||||
{
|
||||
ind = r - ret;
|
||||
if (glob_pattern_p (phe->line) || strchr (phe->line, '\\'))
|
||||
{
|
||||
t = quote_globbing_chars (phe->line);
|
||||
tlen = strlen (t);
|
||||
RESIZE_MALLOCED_BUFFER (ret, ind, tlen, rlen, rlen);
|
||||
r = ret + ind; /* in case reallocated */
|
||||
strcpy (r, t);
|
||||
r += tlen;
|
||||
free (t);
|
||||
}
|
||||
else
|
||||
{
|
||||
tlen = strlen (phe->line);
|
||||
RESIZE_MALLOCED_BUFFER (ret, ind, tlen, rlen, rlen);
|
||||
r = ret + ind; /* in case reallocated */
|
||||
strcpy (r, phe->line);
|
||||
r += len;
|
||||
}
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*p == '\\' && p[1] == '&')
|
||||
p++;
|
||||
|
||||
*r++ = *p++;
|
||||
}
|
||||
*r = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue