fix for exec builtin when the command is not found

This commit is contained in:
Chet Ramey
2022-08-23 09:58:22 -04:00
parent b9ed20acfd
commit 7547afdf73
11 changed files with 400 additions and 10 deletions
+15 -7
View File
@@ -1,6 +1,6 @@
/* setlinebuf.c - line-buffer a stdio stream. */
/* Copyright (C) 1997 Free Software Foundation, Inc.
/* Copyright (C) 1997,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -25,31 +25,39 @@
#include <xmalloc.h>
#if defined (USING_BASH_MALLOC)
# define LBUF_BUFSIZE 1008
# define LBUF_BUFSIZE 2016
#else
# define LBUF_BUFSIZE BUFSIZ
#endif
static char *stdoutbuf = 0;
static char *stderrbuf = 0;
/* Cause STREAM to buffer lines as opposed to characters or blocks. */
int
sh_setlinebuf (stream)
FILE *stream;
{
char *local_linebuf;
#if !defined (HAVE_SETLINEBUF) && !defined (HAVE_SETVBUF)
return (0);
#endif
#if defined (HAVE_SETVBUF)
char *local_linebuf;
#if defined (USING_BASH_MALLOC)
local_linebuf = (char *)xmalloc (LBUF_BUFSIZE);
if (stream == stdout && stdoutbuf == 0)
local_linebuf = stdoutbuf = (char *)xmalloc (LBUF_BUFSIZE);
else if (stream == stderr && stderrbuf == 0)
local_linebuf = stderrbuf = (char *)xmalloc (LBUF_BUFSIZE);
else
local_linebuf = (char *)NULL; /* let stdio handle it */
#else
local_linebuf = (char *)NULL;
#endif
#if defined (HAVE_SETVBUF)
return (setvbuf (stream, local_linebuf, _IOLBF, LBUF_BUFSIZE));
# else /* !HAVE_SETVBUF */
#else /* !HAVE_SETVBUF */
setlinebuf (stream);
return (0);