fixes for glibc time/gettimeofday issue; fix issue with history file containing one line too few if saving timestamps; fix for signal arriving while displaying readline completions

This commit is contained in:
Chet Ramey
2023-03-27 09:28:12 -04:00
parent f539a75606
commit 64b2b7c08d
25 changed files with 344 additions and 125 deletions
+22 -74
View File
@@ -6,7 +6,7 @@
*/
/*
Copyright (C) 1999-2009,2022 Free Software Foundation, Inc.
Copyright (C) 1999-2009,2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -96,8 +96,7 @@ static int pmask;
#define OPTIONS "acdgiflmnopsuACGMP:U"
static int
octal(s)
char *s;
octal(char *s)
{
int r;
@@ -108,9 +107,7 @@ char *s;
}
static int
finfo_main(argc, argv)
int argc;
char **argv;
finfo_main(int argc, char **argv)
{
register int i;
int mode, flags, opt;
@@ -162,8 +159,7 @@ char **argv;
}
static struct stat *
getstat(f)
char *f;
getstat(char *f)
{
static struct stat st;
int fd, r;
@@ -190,8 +186,7 @@ char *f;
}
static int
printfinfo(f)
char *f;
printfinfo(char *f)
{
struct stat *st;
@@ -200,15 +195,13 @@ char *f;
}
static int
getperm(m)
int m;
getperm(int m)
{
return (m & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID));
}
static void
perms(m)
int m;
perms(int m)
{
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
int i;
@@ -251,8 +244,7 @@ int m;
}
static void
printmode(mode)
int mode;
printmode(int mode)
{
if (S_ISBLK(mode))
printf("S_IFBLK ");
@@ -277,8 +269,7 @@ int mode;
}
static int
printst(st)
struct stat *st;
printst(struct stat *st)
{
struct passwd *pw;
struct group *gr;
@@ -314,9 +305,7 @@ struct stat *st;
}
static int
printsome(f, flags)
char *f;
int flags;
printsome(char *f, int flags)
{
struct stat *st;
struct passwd *pw;
@@ -400,8 +389,7 @@ int flags;
#ifndef NOBUILTIN
int
finfo_builtin(list)
WORD_LIST *list;
finfo_builtin(WORD_LIST *list)
{
int c, r;
char **v;
@@ -456,34 +444,26 @@ struct builtin finfo_struct = {
#endif
#ifdef NOBUILTIN
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# if defined (PREFER_VARARGS)
# include <varargs.h>
# endif
#endif
#include <stdarg.h>
char *this_command_name;
main(argc, argv)
int argc;
char **argv;
int
main(int argc, char **argv)
{
this_command_name = argv[0];
exit(finfo_main(argc, argv));
}
void
builtin_usage()
builtin_usage(void)
{
fprintf(stderr, "%s: usage: %s [-%s] [file ...]\n", prog, prog, OPTIONS);
}
#ifndef HAVE_STRERROR
char *
strerror(e)
int e;
strerror(int e)
{
static char ebuf[40];
extern int sys_nerr;
@@ -497,23 +477,20 @@ int e;
}
#endif
char *
xmalloc(s)
size_t s;
PTR_T
xmalloc(size_t s)
{
char *ret;
extern char *malloc();
ret = malloc(s);
if (ret)
return (ret);
fprintf(stderr, "%s: cannot malloc %d bytes\n", prog, s);
fprintf(stderr, "%s: cannot malloc %zu bytes\n", prog, s);
exit(1);
}
char *
base_pathname(p)
char *p;
base_pathname(char *p)
{
char *t;
@@ -523,9 +500,7 @@ char *p;
}
int
legal_number (string, result)
char *string;
long *result;
legal_number (char *string, long result)
{
int sign;
long value;
@@ -584,9 +559,7 @@ extern int optind;
extern char *optarg;
int
sh_getopt(c, v, o)
int c;
char **v, *o;
sh_getopt(int c, char **v, char *o)
{
int r;
@@ -596,43 +569,18 @@ char **v, *o;
return r;
}
#if defined (USE_VARARGS)
void
#if defined (PREFER_STDARG)
builtin_error (const char *format, ...)
#else
builtin_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: ", this_command_name);
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
#endif
vfprintf (stderr, format, args);
va_end (args);
fprintf (stderr, "\n");
}
#else
void
builtin_error (format, arg1, arg2, arg3, arg4, arg5)
char *format, *arg1, *arg2, *arg3, *arg4, *arg5;
{
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: ", this_command_name);
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
fprintf (stderr, "\n");
fflush (stderr);
}
#endif /* !USE_VARARGS */
#endif
+2 -2
View File
@@ -41,9 +41,9 @@
#endif
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid ();
extern struct passwd *getpwuid (uid_t);
#endif
extern struct group *getgrgid ();
extern struct group *getgrgid (gid_t);
#include "shell.h"
#include "builtins.h"
+3 -1
View File
@@ -3,7 +3,7 @@
/* See Makefile for compilation details. */
/*
Copyright (C) 2016,2022 Free Software Foundation, Inc.
Copyright (C) 2016,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -261,6 +261,8 @@ stattime (time_t t, const char *timefmt)
fmt = timefmt ? timefmt : DEFTIMEFMT;
tm = localtime (&t);
if (tm == 0)
return (itos (t));
ret = xmalloc (TIMELEN_MAX);
+6
View File
@@ -80,6 +80,12 @@ strftime_builtin (WORD_LIST *list)
secs = NOW;
t = localtime (&secs);
if (t == 0)
{
builtin_error ("%s: timestamp out of range", list && list->word->word ? list->word->word : "now");
return (EXECUTION_FAILURE);
}
tbsize = strlen (format) * 4;
tbuf = 0;
+1 -1
View File
@@ -58,7 +58,7 @@ static FLIST *tee_flist;
extern int interrupt_immediately;
extern char *strerror ();
extern char *strerror (int);
int
tee_builtin (WORD_LIST *list)
+1 -1
View File
@@ -28,7 +28,7 @@
#include "bashgetopt.h"
#include "common.h"
extern char *ttyname ();
extern char *ttyname (int);
int
tty_builtin (WORD_LIST *list)