mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-21 02:42:51 +02:00
more small fixes to command printing code; simplify readline username completion if getpwent is not available
This commit is contained in:
@@ -7004,3 +7004,24 @@ configure.ac
|
|||||||
- if --enable-static-link is supplied, add -static to LDFLAGS on
|
- if --enable-static-link is supplied, add -static to LDFLAGS on
|
||||||
Linux if opt_profiling isn't enabled
|
Linux if opt_profiling isn't enabled
|
||||||
From a report from Emanuele Torre <torreemanuele6@gmail.com>
|
From a report from Emanuele Torre <torreemanuele6@gmail.com>
|
||||||
|
|
||||||
|
print_cmd.c
|
||||||
|
- make_command_string_internal: if we're recursively printing a list
|
||||||
|
(connection) with more than two elements, don't print any deferred
|
||||||
|
here-documents after the make_command_string_internal on the right
|
||||||
|
side of the connection unless we're at the end of the list
|
||||||
|
(printing_connection == 1). This way the caller gets to add the
|
||||||
|
appropriate connector before printing the deferred here-documents.
|
||||||
|
From a report by Grisha Levit <grishalevit@gmail.com>
|
||||||
|
- make_command_string_internal,print_group_command: after we call
|
||||||
|
PRINT_DEFERRED_HEREDOCS and follow it with a closing `)' (subshell)
|
||||||
|
or `}' (group command), we can set was_heredoc to 0 because we are
|
||||||
|
no longer printing a here-document
|
||||||
|
From a report by Grisha Levit <grishalevit@gmail.com>
|
||||||
|
|
||||||
|
7/3
|
||||||
|
---
|
||||||
|
lib/readline/complete.c
|
||||||
|
- rl_username_completion_function: simplify things by just skipping the
|
||||||
|
function body if HAVE_GETPWENT is not defined.
|
||||||
|
From a report by Grisha Levit <grishalevit@gmail.com>
|
||||||
|
|||||||
@@ -2321,9 +2321,9 @@ rl_completion_matches (const char *text, rl_compentry_func_t *entry_function)
|
|||||||
char *
|
char *
|
||||||
rl_username_completion_function (const char *text, int state)
|
rl_username_completion_function (const char *text, int state)
|
||||||
{
|
{
|
||||||
#if defined (_WIN32) || defined (__OPENNT)
|
#if defined (_WIN32) || defined (__OPENNT) || !defined (HAVE_GETPWENT)
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
#else /* !_WIN32 && !__OPENNT) */
|
#else /* !_WIN32 && !__OPENNT) && HAVE_GETPWENT */
|
||||||
static char *username = (char *)NULL;
|
static char *username = (char *)NULL;
|
||||||
static struct passwd *entry;
|
static struct passwd *entry;
|
||||||
static int namelen, first_char, first_char_loc;
|
static int namelen, first_char, first_char_loc;
|
||||||
@@ -2338,25 +2338,19 @@ rl_username_completion_function (const char *text, int state)
|
|||||||
|
|
||||||
username = savestring (&text[first_char_loc]);
|
username = savestring (&text[first_char_loc]);
|
||||||
namelen = strlen (username);
|
namelen = strlen (username);
|
||||||
#if defined (HAVE_GETPWENT)
|
|
||||||
setpwent ();
|
setpwent ();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (HAVE_GETPWENT)
|
|
||||||
while (entry = getpwent ())
|
while (entry = getpwent ())
|
||||||
{
|
{
|
||||||
/* Null usernames should result in all users as possible completions. */
|
/* Null usernames should result in all users as possible completions. */
|
||||||
if (namelen == 0 || (STREQN (username, entry->pw_name, namelen)))
|
if (namelen == 0 || (STREQN (username, entry->pw_name, namelen)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (entry == 0)
|
if (entry == 0)
|
||||||
{
|
{
|
||||||
#if defined (HAVE_GETPWENT)
|
|
||||||
endpwent ();
|
endpwent ();
|
||||||
#endif
|
|
||||||
return ((char *)NULL);
|
return ((char *)NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2372,7 +2366,7 @@ rl_username_completion_function (const char *text, int state)
|
|||||||
|
|
||||||
return (value);
|
return (value);
|
||||||
}
|
}
|
||||||
#endif /* !_WIN32 && !__OPENNT */
|
#endif /* !_WIN32 && !__OPENNT && HAVE_GETPWENT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return non-zero if CONVFN matches FILENAME up to the length of FILENAME
|
/* Return non-zero if CONVFN matches FILENAME up to the length of FILENAME
|
||||||
|
|||||||
+10
-2
@@ -327,7 +327,13 @@ make_command_string_internal (COMMAND *command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
make_command_string_internal (command->value.Connection->second);
|
make_command_string_internal (command->value.Connection->second);
|
||||||
PRINT_DEFERRED_HEREDOCS ("");
|
/* If this is a recursive call to make_command_string_internal to
|
||||||
|
print a connection with more than two components, defer printing
|
||||||
|
the here-document bodies until our caller can print the
|
||||||
|
connector. Remember that the parser builds lists to be left-side
|
||||||
|
heavy. */
|
||||||
|
if (printing_connection == 1)
|
||||||
|
PRINT_DEFERRED_HEREDOCS ("");
|
||||||
printing_connection--;
|
printing_connection--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -345,6 +351,7 @@ make_command_string_internal (COMMAND *command)
|
|||||||
make_command_string_internal (command->value.Subshell->command);
|
make_command_string_internal (command->value.Subshell->command);
|
||||||
PRINT_DEFERRED_HEREDOCS ("");
|
PRINT_DEFERRED_HEREDOCS ("");
|
||||||
cprintf (" )");
|
cprintf (" )");
|
||||||
|
was_heredoc = 0; /* last wasn't heredoc/newline */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cm_coproc:
|
case cm_coproc:
|
||||||
@@ -698,6 +705,7 @@ print_group_command (GROUP_COM *group_command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cprintf ("}");
|
cprintf ("}");
|
||||||
|
was_heredoc = 0; /* last wasn't heredoc/newline */
|
||||||
|
|
||||||
group_command_nesting--;
|
group_command_nesting--;
|
||||||
}
|
}
|
||||||
@@ -1029,7 +1037,7 @@ print_redirection_list (REDIRECT *redirects)
|
|||||||
was_heredoc = 0;
|
was_heredoc = 0;
|
||||||
while (redirects)
|
while (redirects)
|
||||||
{
|
{
|
||||||
/* Defer printing the here document bodiess until we've printed the rest of the
|
/* Defer printing the here document bodies until we've printed the rest of the
|
||||||
redirections, but print the headers in the order they're given. */
|
redirections, but print the headers in the order they're given. */
|
||||||
if (redirects->instruction == r_reading_until || redirects->instruction == r_deblank_reading_until)
|
if (redirects->instruction == r_reading_until || redirects->instruction == r_deblank_reading_until)
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-4
@@ -103,7 +103,7 @@ bb ()
|
|||||||
foo
|
foo
|
||||||
bar
|
bar
|
||||||
EOF
|
EOF
|
||||||
)
|
);
|
||||||
echo after subshell
|
echo after subshell
|
||||||
}
|
}
|
||||||
mkcoprocs is a function
|
mkcoprocs is a function
|
||||||
@@ -114,13 +114,13 @@ mkcoprocs ()
|
|||||||
producer 1
|
producer 1
|
||||||
EOF1
|
EOF1
|
||||||
|
|
||||||
}
|
};
|
||||||
coproc b {
|
coproc b {
|
||||||
cat <<EOF2
|
cat <<EOF2
|
||||||
producer 2
|
producer 2
|
||||||
EOF2
|
EOF2
|
||||||
|
|
||||||
}
|
};
|
||||||
echo "coprocs created"
|
echo "coprocs created"
|
||||||
}
|
}
|
||||||
mkcoprocs is a function
|
mkcoprocs is a function
|
||||||
@@ -130,6 +130,6 @@ mkcoprocs ()
|
|||||||
heredoc
|
heredoc
|
||||||
body
|
body
|
||||||
EOF
|
EOF
|
||||||
)
|
);
|
||||||
echo "coprocs created"
|
echo "coprocs created"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user