This file is hash.def, from which is created hash.c.
It implements the builtin "hash" in Bash.
-Copyright (C) 1987-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include "common.h"
#include "bashgetopt.h"
+extern int posixly_correct;
extern int dot_found_in_search;
extern char *this_command_name;
we test expunge_hash_table. */
if (list == 0 && expunge_hash_table == 0)
{
- if (print_hashed_commands (list_portably) == 0)
+ opt = print_hashed_commands (list_portably);
+ if (opt == 0 && posixly_correct == 0)
printf (_("%s: hash table empty\n"), this_command_name);
return (EXECUTION_SUCCESS);
#define P_ALLOWESC 0x02
#define P_DQUOTE 0x04
#define P_COMMAND 0x08 /* parsing a command, so look for comments */
+#define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */
static char matched_pair_error;
static char *
int *lenp, flags;
{
int count, ch, was_dollar, in_comment, check_comment;
- int pass_next_character, nestlen, ttranslen, start_lineno;
+ int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno;
char *ret, *nestret, *ttrans;
int retind, retsize, rflags;
count = 1;
- pass_next_character = was_dollar = in_comment = 0;
+ pass_next_character = backq_backslash = was_dollar = in_comment = 0;
check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
/* RFLAGS is the set of flags we want to pass to recursive calls. */
start_lineno = line_number;
while (count)
{
- ch = shell_getc (qc != '\'' && pass_next_character == 0);
+ ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0);
if (ch == EOF)
{
else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1])))
in_comment = 1;
+ /* last char was backslash inside backquoted command substitution */
+ if (backq_backslash)
+ {
+ backq_backslash = 0;
+ /* Placeholder for adding special characters */
+ }
+
if (pass_next_character) /* last char was backslash */
{
pass_next_character = 0;
{
if MBTEST((flags & P_ALLOWESC) && ch == '\\')
pass_next_character++;
+ else if MBTEST((flags & P_BACKQUOTE) && ch == '\\')
+ backq_backslash++;
continue;
}
}
else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
{
- /* Add P_ALLOWESC so backslash quotes the next character and
+ /* Add P_BACKQUOTE so backslash quotes the next character and
shell_getc does the right thing with \<newline>. We do this for
a measure of backwards compatibility -- it's not strictly the
right POSIX thing. */
- nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_ALLOWESC);
+ nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE);
goto add_nestret;
}
else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */