documentation updates; fix for null commands with redirection expansion errors; changes to job notifications for interactive shells sourcing files; fix underflow issue with word_top

This commit is contained in:
Chet Ramey
2024-08-28 11:42:10 -04:00
parent 2e01122fe7
commit 2610d40b32
19 changed files with 175 additions and 21 deletions
+8
View File
@@ -30,6 +30,8 @@
#include "loadables.h"
#if defined (ARRAY_VARS)
#define CSV_ARRAY_DEFAULT "CSV"
#define NQUOTE 0
@@ -99,11 +101,13 @@ csvsplit (SHELL_VAR *csv, char *line, char *dstring)
return (rval = ind); /* number of fields */
}
#endif
int
csv_builtin (WORD_LIST *list)
{
int opt, rval;
#if defined (ARRAY_VARS)
char *array_name, *csvstring;
SHELL_VAR *v;
@@ -164,6 +168,10 @@ csv_builtin (WORD_LIST *list)
opt = csvsplit (v, csvstring, ",");
/* Maybe do something with OPT here, it's the number of fields */
#else
builtin_error ("arrays not available");
rval = EXECUTION_FAILURE;
#endif
return (rval);
}
+15
View File
@@ -178,7 +178,9 @@ cutbytes (SHELL_VAR *v, char *line, struct cutop *ops)
if (v)
{
ind = 0;
#if defined (ARRAY_VARS)
bind_array_element (v, ind, buf, 0);
#endif
ind++;
}
else
@@ -246,7 +248,9 @@ cutchars (SHELL_VAR *v, char *line, struct cutop *ops)
if (v)
{
ind = 0;
#if defined (ARRAY_VARS)
bind_array_element (v, ind, buf, 0);
#endif
ind++;
}
else
@@ -301,7 +305,9 @@ cutfields (SHELL_VAR *v, char *line, struct cutop *ops)
return ind;
if (v)
{
#if defined (ARRAY_VARS)
bind_array_element (v, ind, line, 0);
#endif
ind++;
}
else
@@ -330,12 +336,14 @@ cutfields (SHELL_VAR *v, char *line, struct cutop *ops)
{
if (bmap[b] == 0)
continue;
#if defined (ARRAY_VARS)
if (v)
{
bind_array_element (v, ind, fields[b], 0);
ind++;
}
else
#endif
{
if (i == 0)
putchar (ops->delim);
@@ -441,8 +449,13 @@ cut_internal (int which, WORD_LIST *list)
switch (opt)
{
case 'a':
#if defined (ARRAY_VARS)
array_name = list_optarg;
break;
#else
builtin_error ("arrays not available");
return (EX_USAGE);
#endif
case 'b':
cutflags |= BFLAG;
list_arg = list_optarg;
@@ -502,6 +515,7 @@ cut_internal (int which, WORD_LIST *list)
return (EXECUTION_FAILURE);
}
#if defined (ARRAY_VARS)
if (array_name)
{
v = builtin_find_indexed_array (array_name, 1);
@@ -511,6 +525,7 @@ cut_internal (int which, WORD_LIST *list)
return (EXECUTION_FAILURE);
}
}
#endif
op.flags = cutflags;
op.delim = delim;
+8
View File
@@ -30,6 +30,8 @@
#include "loadables.h"
#if defined (ARRAY_VARS)
#define DSV_ARRAY_DEFAULT "DSV"
#define NQUOTE 0
@@ -158,11 +160,13 @@ dsvsplit (SHELL_VAR *dsv, char *line, char *dstring, int flags)
return (rval = ind); /* number of fields */
}
#endif
int
dsv_builtin (WORD_LIST *list)
{
int opt, rval, flags;
#if defined (ARRAY_VARS)
char *array_name, *dsvstring, *delims;
SHELL_VAR *v;
@@ -238,6 +242,10 @@ dsv_builtin (WORD_LIST *list)
opt = dsvsplit (v, dsvstring, delims, flags);
/* Maybe do something with OPT here, it's the number of fields */
#else
builtin_error ("arrays not available");
rval = EXECUTION_FAILURE;
#endif
return (rval);
}
+8
View File
@@ -37,6 +37,8 @@
extern int errno;
#endif
#if defined (ARRAY_VARS)
#define KV_ARRAY_DEFAULT "KV"
/* Split LINE into a key and value, with the delimiter between the key and
@@ -113,10 +115,12 @@ kvfile (SHELL_VAR *v, int fd, char *delims, char *rs)
QUIT;
return nr;
}
#endif
int
kv_builtin (WORD_LIST *list)
{
#if defined (ARRAY_VARS)
int opt, rval, free_delims;
char *array_name, *delims, *rs;
SHELL_VAR *v;
@@ -192,6 +196,10 @@ kv_builtin (WORD_LIST *list)
if (free_delims)
free (delims); /* getifs returns allocated memory */
return (rval > 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
#else
builtin_error ("arrays not available");
return (EXECUTION_FAILURE);
#endif
}
/* Called when builtin is enabled and loaded from the shared object. If this
+2
View File
@@ -165,10 +165,12 @@ realpath_builtin(WORD_LIST *list)
builtin_error("%s: %s", p, strerror(errno));
continue;
}
#if defined (ARRAY_VARS)
if (aflag) {
bind_array_element (v, ind, r, 0);
ind++;
}
#endif
if (qflag == 0) {
if (vflag)
printf ("%s -> ", p);
+8
View File
@@ -46,6 +46,8 @@
extern int errno;
#endif
#if defined (ARRAY_VARS)
#define ST_NAME 0
#define ST_DEV 1
#define ST_INO 2
@@ -334,10 +336,12 @@ loadstat (char *vname, SHELL_VAR *var, char *fname, int flags, char *fmt, struct
}
return 0;
}
#endif
int
stat_builtin (WORD_LIST *list)
{
#if defined (ARRAY_VARS)
int opt, flags;
char *aname, *fname, *timefmt;
struct stat st;
@@ -410,6 +414,10 @@ stat_builtin (WORD_LIST *list)
}
return (EXECUTION_SUCCESS);
#else
builtin_error ("arrays not available");
return (EXECUTION_FAILURE);
#endif
}
/* An array of strings forming the `long' documentation for a builtin xxx,