mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-07 12:20:50 +02:00
Bash-5.3-alpha release
This commit is contained in:
@@ -102,7 +102,7 @@ cc_t old_vtime;
|
||||
struct termios term;
|
||||
|
||||
int
|
||||
main()
|
||||
main(int c, char **v)
|
||||
{
|
||||
fd_set fds;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* fileman.c - file manager example for readline library. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -61,24 +61,24 @@
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
extern char *xmalloc PARAMS((size_t));
|
||||
extern char *xmalloc (size_t);
|
||||
|
||||
void initialize_readline PARAMS((void));
|
||||
void too_dangerous PARAMS((char *));
|
||||
void initialize_readline (void);
|
||||
void too_dangerous (char *);
|
||||
|
||||
int execute_line PARAMS((char *));
|
||||
int valid_argument PARAMS((char *, char *));
|
||||
int execute_line (char *);
|
||||
int valid_argument (char *, char *);
|
||||
|
||||
/* The names of functions that actually do the manipulation. */
|
||||
int com_list PARAMS((char *));
|
||||
int com_view PARAMS((char *));
|
||||
int com_rename PARAMS((char *));
|
||||
int com_stat PARAMS((char *));
|
||||
int com_pwd PARAMS((char *));
|
||||
int com_delete PARAMS((char *));
|
||||
int com_help PARAMS((char *));
|
||||
int com_cd PARAMS((char *));
|
||||
int com_quit PARAMS((char *));
|
||||
int com_list (char *);
|
||||
int com_view (char *);
|
||||
int com_rename (char *);
|
||||
int com_stat (char *);
|
||||
int com_pwd (char *);
|
||||
int com_delete (char *);
|
||||
int com_help (char *);
|
||||
int com_cd (char *);
|
||||
int com_quit (char *);
|
||||
|
||||
/* A structure which contains information on the commands this program
|
||||
can understand. */
|
||||
@@ -105,8 +105,11 @@ COMMAND commands[] = {
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
char *stripwhite ();
|
||||
COMMAND *find_command ();
|
||||
char *dupstr (char *);
|
||||
int execute_line (char *);
|
||||
char *stripwhite (char *);
|
||||
|
||||
COMMAND *find_command (char *);
|
||||
|
||||
/* The name of this program, as taken from argv[0]. */
|
||||
char *progname;
|
||||
@@ -115,8 +118,7 @@ char *progname;
|
||||
int done;
|
||||
|
||||
char *
|
||||
dupstr (s)
|
||||
char *s;
|
||||
dupstr (char *s)
|
||||
{
|
||||
char *r;
|
||||
|
||||
@@ -125,45 +127,9 @@ dupstr (s)
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *line, *s;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
initialize_readline (); /* Bind our completer. */
|
||||
|
||||
/* Loop reading and executing lines until the user quits. */
|
||||
for ( ; done == 0; )
|
||||
{
|
||||
line = readline ("FileMan: ");
|
||||
|
||||
if (!line)
|
||||
break;
|
||||
|
||||
/* Remove leading and trailing whitespace from the line.
|
||||
Then, if there is anything left, add it to the history list
|
||||
and execute it. */
|
||||
s = stripwhite (line);
|
||||
|
||||
if (*s)
|
||||
{
|
||||
add_history (s);
|
||||
execute_line (s);
|
||||
}
|
||||
|
||||
free (line);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/* Execute a command line. */
|
||||
int
|
||||
execute_line (line)
|
||||
char *line;
|
||||
execute_line (char *line)
|
||||
{
|
||||
register int i;
|
||||
COMMAND *command;
|
||||
@@ -202,8 +168,7 @@ execute_line (line)
|
||||
/* Look up NAME as the name of a command, and return a pointer to that
|
||||
command. Return a NULL pointer if NAME isn't a command name. */
|
||||
COMMAND *
|
||||
find_command (name)
|
||||
char *name;
|
||||
find_command (char *name)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -217,8 +182,7 @@ find_command (name)
|
||||
/* Strip whitespace from the start and end of STRING. Return a pointer
|
||||
into STRING. */
|
||||
char *
|
||||
stripwhite (string)
|
||||
char *string;
|
||||
stripwhite (char *string)
|
||||
{
|
||||
register char *s, *t;
|
||||
|
||||
@@ -242,14 +206,14 @@ stripwhite (string)
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
char *command_generator PARAMS((const char *, int));
|
||||
char **fileman_completion PARAMS((const char *, int, int));
|
||||
char *command_generator (const char *, int);
|
||||
char **fileman_completion (const char *, int, int);
|
||||
|
||||
/* Tell the GNU Readline library how to complete. We want to try to complete
|
||||
on command names if this is the first word in the line, or on filenames
|
||||
if not. */
|
||||
void
|
||||
initialize_readline ()
|
||||
initialize_readline (void)
|
||||
{
|
||||
/* Allow conditional parsing of the ~/.inputrc file. */
|
||||
rl_readline_name = "FileMan";
|
||||
@@ -264,9 +228,7 @@ initialize_readline ()
|
||||
in case we want to do some simple parsing. Return the array of matches,
|
||||
or NULL if there aren't any. */
|
||||
char **
|
||||
fileman_completion (text, start, end)
|
||||
const char *text;
|
||||
int start, end;
|
||||
fileman_completion (const char *text, int start, int end)
|
||||
{
|
||||
char **matches;
|
||||
|
||||
@@ -285,9 +247,7 @@ fileman_completion (text, start, end)
|
||||
to start from scratch; without any state (i.e. STATE == 0), then we
|
||||
start at the top of the list. */
|
||||
char *
|
||||
command_generator (text, state)
|
||||
const char *text;
|
||||
int state;
|
||||
command_generator (const char *text, int state)
|
||||
{
|
||||
static int list_index, len;
|
||||
char *name;
|
||||
@@ -326,43 +286,39 @@ static char syscom[1024];
|
||||
|
||||
/* List the file(s) named in arg. */
|
||||
int
|
||||
com_list (arg)
|
||||
char *arg;
|
||||
com_list (char *arg)
|
||||
{
|
||||
if (!arg)
|
||||
arg = "";
|
||||
|
||||
sprintf (syscom, "ls -FClg %s", arg);
|
||||
snprintf (syscom, sizeof (syscom), "ls -FClg %s", arg);
|
||||
return (system (syscom));
|
||||
}
|
||||
|
||||
int
|
||||
com_view (arg)
|
||||
char *arg;
|
||||
com_view (char *arg)
|
||||
{
|
||||
if (!valid_argument ("view", arg))
|
||||
return 1;
|
||||
|
||||
#if defined (__MSDOS__)
|
||||
/* more.com doesn't grok slashes in pathnames */
|
||||
sprintf (syscom, "less %s", arg);
|
||||
snprintf (syscom, sizeof (syscom), "less %s", arg);
|
||||
#else
|
||||
sprintf (syscom, "more %s", arg);
|
||||
snprintf (syscom, sizeof (syscom), "more %s", arg);
|
||||
#endif
|
||||
return (system (syscom));
|
||||
}
|
||||
|
||||
int
|
||||
com_rename (arg)
|
||||
char *arg;
|
||||
com_rename (char *arg)
|
||||
{
|
||||
too_dangerous ("rename");
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
com_stat (arg)
|
||||
char *arg;
|
||||
com_stat (char *arg)
|
||||
{
|
||||
struct stat finfo;
|
||||
|
||||
@@ -390,8 +346,7 @@ com_stat (arg)
|
||||
}
|
||||
|
||||
int
|
||||
com_delete (arg)
|
||||
char *arg;
|
||||
com_delete (char *arg)
|
||||
{
|
||||
too_dangerous ("delete");
|
||||
return (1);
|
||||
@@ -400,8 +355,7 @@ com_delete (arg)
|
||||
/* Print out help for ARG, or for all of the commands if ARG is
|
||||
not present. */
|
||||
int
|
||||
com_help (arg)
|
||||
char *arg;
|
||||
com_help (char *arg)
|
||||
{
|
||||
register int i;
|
||||
int printed = 0;
|
||||
@@ -440,8 +394,7 @@ com_help (arg)
|
||||
|
||||
/* Change to the directory ARG. */
|
||||
int
|
||||
com_cd (arg)
|
||||
char *arg;
|
||||
com_cd (char *arg)
|
||||
{
|
||||
if (chdir (arg) == -1)
|
||||
{
|
||||
@@ -455,8 +408,7 @@ com_cd (arg)
|
||||
|
||||
/* Print out the current working directory. */
|
||||
int
|
||||
com_pwd (ignore)
|
||||
char *ignore;
|
||||
com_pwd (char *ignore)
|
||||
{
|
||||
char dir[1024], *s;
|
||||
|
||||
@@ -473,8 +425,7 @@ com_pwd (ignore)
|
||||
|
||||
/* The user wishes to quit using this program. Just set DONE non-zero. */
|
||||
int
|
||||
com_quit (arg)
|
||||
char *arg;
|
||||
com_quit (char *arg)
|
||||
{
|
||||
done = 1;
|
||||
return (0);
|
||||
@@ -482,8 +433,7 @@ com_quit (arg)
|
||||
|
||||
/* Function which tells you that you can't do this. */
|
||||
void
|
||||
too_dangerous (caller)
|
||||
char *caller;
|
||||
too_dangerous (char *caller)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: Too dangerous for me to distribute. Write it yourself.\n",
|
||||
@@ -493,8 +443,7 @@ too_dangerous (caller)
|
||||
/* Return non-zero if ARG is a valid argument for CALLER, else print
|
||||
an error message and return zero. */
|
||||
int
|
||||
valid_argument (caller, arg)
|
||||
char *caller, *arg;
|
||||
valid_argument (char *caller, char *arg)
|
||||
{
|
||||
if (!arg || !*arg)
|
||||
{
|
||||
@@ -504,3 +453,36 @@ valid_argument (caller, arg)
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *line, *s;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
initialize_readline (); /* Bind our completer. */
|
||||
|
||||
/* Loop reading and executing lines until the user quits. */
|
||||
for ( ; done == 0; )
|
||||
{
|
||||
line = readline ("FileMan: ");
|
||||
|
||||
if (!line)
|
||||
break;
|
||||
|
||||
/* Remove leading and trailing whitespace from the line.
|
||||
Then, if there is anything left, add it to the history list
|
||||
and execute it. */
|
||||
s = stripwhite (line);
|
||||
|
||||
if (*s)
|
||||
{
|
||||
add_history (s);
|
||||
execute_line (s);
|
||||
}
|
||||
|
||||
free (line);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char line[1024], *t;
|
||||
int len, done;
|
||||
@@ -91,6 +89,7 @@ main (argc, argv)
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
time_t tt;
|
||||
struct tm *tm;
|
||||
char timestr[128];
|
||||
|
||||
the_list = history_list ();
|
||||
@@ -98,8 +97,9 @@ main (argc, argv)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
{
|
||||
tt = history_get_time (the_list[i]);
|
||||
if (tt)
|
||||
strftime (timestr, sizeof (timestr), "%a %R", localtime(&tt));
|
||||
tm = tt ? localtime (&tt) : 0;
|
||||
if (tm)
|
||||
strftime (timestr, sizeof (timestr), "%a %R", tm);
|
||||
else
|
||||
strcpy (timestr, "??");
|
||||
printf ("%d: %s: %s\n", i + history_base, timestr, the_list[i]->line);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* manexamp.c -- The examples which appear in the documentation are here. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -18,9 +18,35 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@@ -33,7 +59,7 @@ static char *line_read = (char *)NULL;
|
||||
|
||||
/* Read a string, and return a pointer to it. Returns NULL on EOF. */
|
||||
char *
|
||||
rl_gets ()
|
||||
rl_gets (void)
|
||||
{
|
||||
/* If the buffer has already been allocated, return the memory
|
||||
to the free pool. */
|
||||
@@ -60,10 +86,11 @@ rl_gets ()
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Invert the case of the COUNT following characters. */
|
||||
invert_case_line (count, key)
|
||||
int count, key;
|
||||
int
|
||||
invert_case_line (int count, int key)
|
||||
{
|
||||
register int start, end;
|
||||
int start, end;
|
||||
int direction;
|
||||
|
||||
start = rl_point;
|
||||
|
||||
@@ -92,7 +119,7 @@ invert_case_line (count, key)
|
||||
}
|
||||
|
||||
if (start == end)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
/* Tell readline that we are modifying the line, so save the undo
|
||||
information. */
|
||||
@@ -108,4 +135,5 @@ invert_case_line (count, key)
|
||||
|
||||
/* Move point to on top of the last character changed. */
|
||||
rl_point = end - direction;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -55,15 +55,11 @@ extern void exit();
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strrchr();
|
||||
#endif
|
||||
|
||||
static char *progname;
|
||||
static char *deftext;
|
||||
|
||||
static int
|
||||
set_deftext ()
|
||||
set_deftext (void)
|
||||
{
|
||||
if (deftext)
|
||||
{
|
||||
@@ -75,16 +71,14 @@ set_deftext ()
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
|
||||
progname, progname);
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *temp, *prompt;
|
||||
struct stat sb;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* usage: rlcat
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -64,27 +64,26 @@ extern int errno;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
static int stdcat();
|
||||
static int fcopy(FILE *);
|
||||
static int stdcat(int, char **);
|
||||
|
||||
static char *progname;
|
||||
static int vflag;
|
||||
|
||||
static void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
fprintf (stderr, "%s: usage: %s [-vEVN] [filename]\n", progname, progname);
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *temp;
|
||||
int opt, Vflag, Nflag;
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
setlocale (LC_ALL, ""):
|
||||
setlocale (LC_ALL, "");
|
||||
#endif
|
||||
|
||||
progname = strrchr(argv[0], '/');
|
||||
@@ -134,8 +133,7 @@ main (argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
fcopy(fp)
|
||||
FILE *fp;
|
||||
fcopy(FILE *fp)
|
||||
{
|
||||
int c;
|
||||
char *x;
|
||||
@@ -155,9 +153,7 @@ fcopy(fp)
|
||||
}
|
||||
|
||||
int
|
||||
stdcat (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
stdcat (int argc, char **argv)
|
||||
{
|
||||
int i, fd, r;
|
||||
char *s;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -48,10 +48,8 @@ extern void exit();
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
extern HIST_ENTRY **history_list ();
|
||||
|
||||
int
|
||||
main ()
|
||||
main (int c, char **v)
|
||||
{
|
||||
char *temp, *prompt;
|
||||
int done;
|
||||
|
||||
Reference in New Issue
Block a user