diff options
author | Jari Aalto <jari.aalto@cante.net> | 2000-03-17 21:46:59 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:53 +0000 |
commit | bb70624e964126b7ac4ff085ba163a9c35ffa18f (patch) | |
tree | ba2dd4add13ada94b1899c6d4aca80195b80b74b /bashhist.c | |
parent | b72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (diff) | |
download | android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.gz android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.bz2 android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.zip |
Imported from ../bash-2.04.tar.gz.
Diffstat (limited to 'bashhist.c')
-rw-r--r-- | bashhist.c | 75 |
1 files changed, 34 insertions, 41 deletions
@@ -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; } |