mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Add /dev/fd support to Windows
GNU bash needs this functionality, otherwise it can't do <(cmd...).
This commit is contained in:
parent
2e5f662dfe
commit
b3fb6cff43
6 changed files with 113 additions and 6 deletions
1
third_party/bash/README.cosmo
vendored
1
third_party/bash/README.cosmo
vendored
|
@ -13,3 +13,4 @@ ORIGIN
|
|||
LOCAL CHANGES
|
||||
|
||||
- Force disable mkfifo() code
|
||||
- Added runtime check for broken BSD /dev/fd stuff
|
||||
|
|
4
third_party/bash/config.h
vendored
4
third_party/bash/config.h
vendored
|
@ -542,7 +542,7 @@
|
|||
#define HAVE_HASH_BANG_EXEC 1
|
||||
|
||||
/* Define if you have the /dev/fd devices to map open files into the file system. */
|
||||
/* #define HAVE_DEV_FD 1 */
|
||||
#define HAVE_DEV_FD 1
|
||||
|
||||
/* Defined to /dev/fd or /proc/self/fd (linux). */
|
||||
#define DEV_FD_PREFIX "/dev/fd/"
|
||||
|
@ -1160,7 +1160,7 @@
|
|||
|
||||
/* #undef GETCWD_BROKEN */
|
||||
|
||||
/* #undef DEV_FD_STAT_BROKEN */
|
||||
#define DEV_FD_STAT_BROKEN
|
||||
|
||||
/* An array implementation that prioritizes speed (O(1) access) over space,
|
||||
in array2.c */
|
||||
|
|
10
third_party/bash/eaccess.c
vendored
10
third_party/bash/eaccess.c
vendored
|
@ -1,3 +1,4 @@
|
|||
#include "libc/dce.h"
|
||||
/* eaccess.c - eaccess replacement for the shell, plus other access functions. */
|
||||
|
||||
/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
|
||||
|
@ -93,7 +94,8 @@ sh_stat (path, finfo)
|
|||
{
|
||||
/* If stating /dev/fd/n doesn't produce the same results as fstat of
|
||||
FD N, then define DEV_FD_STAT_BROKEN */
|
||||
#if !defined (HAVE_DEV_FD) || defined (DEV_FD_STAT_BROKEN)
|
||||
//#if !defined (HAVE_DEV_FD) || defined (DEV_FD_STAT_BROKEN)
|
||||
if (IsBsd()) {//[jart]
|
||||
intmax_t fd;
|
||||
int r;
|
||||
|
||||
|
@ -105,7 +107,8 @@ sh_stat (path, finfo)
|
|||
}
|
||||
errno = ENOENT;
|
||||
return (-1);
|
||||
#else
|
||||
//#else
|
||||
} else {//[jart]
|
||||
/* If HAVE_DEV_FD is defined, DEV_FD_PREFIX is defined also, and has a
|
||||
trailing slash. Make sure /dev/fd/xx really uses DEV_FD_PREFIX/xx.
|
||||
On most systems, with the notable exception of linux, this is
|
||||
|
@ -114,7 +117,8 @@ sh_stat (path, finfo)
|
|||
strcpy (pbuf, DEV_FD_PREFIX);
|
||||
strcat (pbuf, path + 8);
|
||||
return (stat (pbuf, finfo));
|
||||
#endif /* !HAVE_DEV_FD */
|
||||
//#endif /* !HAVE_DEV_FD */
|
||||
}//[jart]
|
||||
}
|
||||
#if !defined (HAVE_DEV_STDIN)
|
||||
else if (STREQN (path, "/dev/std", 8))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue