bash-5.2-beta release

This commit is contained in:
Chet Ramey
2022-04-13 11:01:08 -04:00
parent 4491c03014
commit 187661b892
119 changed files with 14991 additions and 12391 deletions
+7 -7
View File
@@ -39,9 +39,9 @@
element of array variable CSV, starting at index 0. The format of LINE is
as described in RFC 4180. */
static int
csvsplit (csv, line)
csvsplit (csv, line, dstring)
SHELL_VAR *csv;
char *line;
char *line, *dstring;
{
arrayind_t ind;
char *field, *prev, *buf, *xbuf;
@@ -67,7 +67,7 @@ csvsplit (csv, line)
buf[b++] = *field++; /* skip double quote */
else if (qstate == DQUOTE && *field == '"')
qstate = NQUOTE;
else if (qstate == NQUOTE && *field == ',')
else if (qstate == NQUOTE && *field == *dstring)
break;
else
/* This copies any text between a closing double quote and the
@@ -80,7 +80,7 @@ csvsplit (csv, line)
else
{
buf = prev;
field = prev + strcspn (prev, ",");
field = prev + strcspn (prev, dstring);
}
delim = *field;
@@ -91,10 +91,10 @@ csvsplit (csv, line)
*field = delim;
if (delim == ',')
if (delim == *dstring)
prev = field + 1;
}
while (delim == ',');
while (delim == *dstring);
if (xbuf)
free (xbuf);
@@ -165,7 +165,7 @@ csv_builtin (list)
if (csvstring == 0 || *csvstring == 0)
return (EXECUTION_SUCCESS);
opt = csvsplit (v, csvstring);
opt = csvsplit (v, csvstring, ",");
/* Maybe do something with OPT here, it's the number of fields */
return (rval);
+12 -5
View File
@@ -3,23 +3,24 @@
*/
#include <config.h>
#include <fcntl.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#include "common.h"
#ifndef errno
extern int errno;
#endif
extern char **make_builtin_argv ();
extern char **make_builtin_argv (WORD_LIST *, int *);
extern char **export_env;
extern int perl_main();
extern void perl_close(void);
extern int perl_main(int, char **, char **);
bperl_builtin(list)
WORD_LIST *list;
int
bperl_builtin(WORD_LIST *list)
{
char **v;
int c, r;
@@ -31,6 +32,12 @@ WORD_LIST *list;
return r;
}
void
bperl_builtin_unload (char *s)
{
perl_close();
}
char *bperl_doc[] = {
"An interface to a perl5 interpreter.",
(char *)0
+15 -1
View File
@@ -1,15 +1,29 @@
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
extern void xs_init _((void));
#define iperl my_perl /* I guess the name `my_perl' is required */
extern void xs_init (pTHX);
static PerlInterpreter *iperl; /*** The Perl interpreter ***/
static int first = 1;
void
perl_close (void)
{
PERL_SYS_TERM();
}
int
perl_main(int argc, char **argv, char **env)
{
int r;
if (first) {
first = 0;
PERL_SYS_INIT3(&argc, &argv, &env);
}
iperl = perl_alloc();
perl_construct(iperl);
perl_parse(iperl, xs_init, argc, argv, (char **)NULL);
+29 -28
View File
@@ -1,13 +1,13 @@
/*
* realpath -- canonicalize pathnames, resolving symlinks
*
* usage: realpath [-csv] [-a name] pathname [pathname...]
* usage: realpath [-cqsv] [-a name] pathname [pathname...]
*
* options: -a name assign each canonicalized pathname to indexed array
* variable NAME
* -c check whether or not each resolved path exists
* -s no output, exit status determines whether path is valid
* -S strip . and .. from the pathname only, no symlink resolution
* -q no output, exit status determines whether path is valid
* -s strip . and .. from the pathname only, no symlink resolution
* -v produce verbose output
*
*
@@ -22,7 +22,7 @@
*/
/*
Copyright (C) 1999-2009,2021 Free Software Foundation, Inc.
Copyright (C) 1999-2009,2021,2022 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -66,7 +66,7 @@ extern char *sh_realpath();
int
realpath_builtin(WORD_LIST *list)
{
int opt, cflag, vflag, sflag, Sflag, aflag, es;
int opt, cflag, vflag, qflag, sflag, aflag, es;
char *r, realbuf[PATH_MAX], *p, *newpath;
struct stat sb;
#if defined (ARRAY_VARS)
@@ -80,14 +80,14 @@ realpath_builtin(WORD_LIST *list)
return (EX_USAGE);
}
vflag = cflag = sflag = aflag = Sflag = 0;
vflag = cflag = qflag = aflag = sflag = 0;
#if defined (ARRAY_VARS)
aname = NULL;
v = NULL;
ind = 0;
#endif
reset_internal_getopt();
while ((opt = internal_getopt (list, "a:Scsv")) != -1) {
while ((opt = internal_getopt (list, "a:cqsv")) != -1) {
switch (opt) {
#if defined (ARRAY_VARS)
case 'a':
@@ -98,12 +98,12 @@ realpath_builtin(WORD_LIST *list)
case 'c':
cflag = 1;
break;
case 'q':
qflag = 1;
break;
case 's':
sflag = 1;
break;
case 'S':
Sflag = 1;
break;
case 'v':
vflag = 1;
break;
@@ -146,7 +146,7 @@ realpath_builtin(WORD_LIST *list)
for (es = EXECUTION_SUCCESS; list; list = list->next) {
p = list->word->word;
if (Sflag) {
if (sflag) {
/* sh_canonpath doesn't convert to absolute pathnames */
newpath = make_absolute(p, get_string_value("PWD"));
r = sh_canonpath(newpath, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
@@ -155,27 +155,26 @@ realpath_builtin(WORD_LIST *list)
r = sh_realpath(p, realbuf);
if (r == 0) {
es = EXECUTION_FAILURE;
if (sflag == 0)
if (qflag == 0)
builtin_error("%s: cannot resolve: %s", p, strerror(errno));
continue;
}
if (cflag && (stat(r, &sb) < 0)) {
es = EXECUTION_FAILURE;
if (sflag == 0)
if (qflag == 0)
builtin_error("%s: %s", p, strerror(errno));
continue;
}
if (sflag == 0) {
if (aflag) {
bind_array_element (v, ind, r, 0);
ind++;
} else {
if (vflag)
printf ("%s -> ", p);
printf("%s\n", r);
}
if (aflag) {
bind_array_element (v, ind, r, 0);
ind++;
}
if (Sflag)
if (qflag == 0) {
if (vflag)
printf ("%s -> ", p);
printf("%s\n", r);
}
if (sflag)
free (r);
}
return es;
@@ -186,11 +185,13 @@ char *realpath_doc[] = {
"",
"Display the canonicalized version of each PATHNAME argument, resolving",
"symbolic links.",
"If the -S option is supplied, canonicalize . and .. pathname components",
"without resolving symbolic links.",
"The -a option stores each canonicalized PATHNAME argument into the indexed",
"array VARNAME.",
"The -c option checks whether or not each resolved name exists.",
"The -s option produces no output; the exit status determines the",
"validity of each PATHNAME.",
"The -q option produces no output; the exit status determines the",
"validity of each PATHNAME, but any array assignment is still performed.",
"If the -s option is supplied, canonicalize . and .. pathname components",
"without resolving symbolic links.",
"The -v option produces verbose output.",
"The exit status is 0 if each PATHNAME was resolved; non-zero otherwise.",
(char *)NULL
@@ -201,6 +202,6 @@ struct builtin realpath_struct = {
realpath_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */
realpath_doc, /* array of long documentation strings */
"realpath [-Scsv] pathname [pathname...]", /* usage synopsis */
"realpath [-a varname] [-cqsv] pathname [pathname...]", /* usage synopsis */
0 /* reserved for internal use */
};
+16 -6
View File
@@ -3,7 +3,7 @@
/* See Makefile for compilation details. */
/*
Copyright (C) 2016 Free Software Foundation, Inc.
Copyright (C) 2016,2022 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -390,6 +390,12 @@ stat_builtin (list)
}
}
if (legal_identifier (aname) == 0)
{
sh_invalidid (aname);
return (EXECUTION_FAILURE);
}
list = loptend;
if (list == 0)
{
@@ -397,6 +403,10 @@ stat_builtin (list)
return (EX_USAGE);
}
#if 0
unbind_variable (aname);
#endif
fname = list->word->word;
if (getstat (fname, flags, &st) < 0)
@@ -405,8 +415,7 @@ stat_builtin (list)
return (EXECUTION_FAILURE);
}
unbind_variable (aname);
v = make_new_assoc_variable (aname);
v = find_or_make_array_variable (aname, 3);
if (v == 0)
{
builtin_error ("%s: cannot create variable", aname);
@@ -430,9 +439,10 @@ char *stat_doc[] = {
"",
"Take a filename and load the status information returned by a",
"stat(2) call on that file into the associative array specified",
"by the -A option. The default array name is STAT. If the -L",
"option is supplied, stat does not resolve symbolic links and",
"reports information about the link itself. The -l option results",
"by the -A option. The default array name is STAT.",
"",
"If the -L option is supplied, stat does not resolve symbolic links",
"and reports information about the link itself. The -l option results",
"in longer-form listings for some of the fields. When -l is used,",
"the -F option supplies a format string passed to strftime(3) to",
"display the file time information.",