commit: 4d3552c6223cf4b6ea85583a8a4dbf29e51319be
Author: Michael Haubenwallner <michael.haubenwallner <AT> ssi-schaefer
<DOT> com>
AuthorDate: Wed Apr 13 07:52:29 2016 +0000
Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
CommitDate: Wed Apr 13 11:46:29 2016 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=4d3552c6
bash-4.3_p39: add cygwin patch
app-shells/bash/bash-4.3_p39.ebuild | 2 +
app-shells/bash/files/bash-4.3_p39-cygwin-r2.patch | 690 +++++++++++++++++++++
2 files changed, 692 insertions(+)
diff --git a/app-shells/bash/bash-4.3_p39.ebuild
b/app-shells/bash/bash-4.3_p39.ebuild
index 549dee6..e38462f 100644
--- a/app-shells/bash/bash-4.3_p39.ebuild
+++ b/app-shells/bash/bash-4.3_p39.ebuild
@@ -94,6 +94,8 @@ src_prepare() {
epatch "${FILESDIR}"/${PN}-4.0-bashintl-in-siglist.patch
+ epatch "${FILESDIR}"/${P}-cygwin-r2.patch
+
# Nasty trick to set bashbug's shebang to bash instead of sh. We don't
have
# sh while bootstrapping for the first time, This works around bug
309825
sed -i -e '1s:sh:bash:' support/bashbug.sh || die
diff --git a/app-shells/bash/files/bash-4.3_p39-cygwin-r2.patch
b/app-shells/bash/files/bash-4.3_p39-cygwin-r2.patch
new file mode 100644
index 0000000..1a0ffc3
--- /dev/null
+++ b/app-shells/bash/files/bash-4.3_p39-cygwin-r2.patch
@@ -0,0 +1,690 @@
+based on Cygwin bash-4.3.39-2.src package
+
+--- origsrc/bash-4.3/bashline.c 2015-06-01 22:41:57.804475900 -0600
++++ src/bash-4.3/bashline.c 2015-06-02 22:22:59.745114200 -0600
+@@ -264,6 +274,11 @@ int no_empty_command_completion;
+ are the only possible matches, even if FIGNORE says to. */
+ int force_fignore = 1;
+
++#if __CYGWIN__
++/* If set, shorten "foo.exe" to "foo" when they are the same file. */
++int completion_strip_exe;
++#endif /* __CYGWIN__ */
++
+ /* Perform spelling correction on directory names during word completion */
+ int dircomplete_spelling = 0;
+
+@@ -2109,6 +2127,21 @@ globword:
+
+ if (match && executable_completion ((searching_path ? val : cval),
searching_path))
+ {
++#if __CYGWIN__
++ if (completion_strip_exe)
++ {
++ size_t val_len = strlen (val);
++ char *candidate;
++ if (val_len > 4 && !strcasecmp (&val[val_len - 4], ".exe")
++ && (candidate = strdup (val)))
++ {
++ candidate[val_len - 4] = '\0';
++ if (same_file (val, candidate, NULL, NULL))
++ temp[strlen (temp) - 4] = '\0';
++ free (candidate);
++ }
++ }
++#endif
+ if (cval != val)
+ free (cval);
+ free (val);
+@@ -2844,6 +2877,17 @@ test_for_directory (name)
+ int r;
+
+ fn = bash_tilde_expand (name, 0);
++#if __CYGWIN__
++ /* stat("//server") can only be successful as a directory, but takes
++ a several-second timeout to fail. It is much faster to assume
++ that //server is a valid name than it is to wait for the stat,
++ even though it gives false positives on bad names. */
++ if (fn[0] == '/' && fn[1] == '/' && ! strchr (&fn[2], '/'))
++ {
++ free (fn);
++ return 1;
++ }
++#endif /* __CYGWIN__ */
+ r = file_isdir (fn);
+ free (fn);
+
+--- origsrc/bash-4.3/builtins/set.def 2015-06-01 22:41:57.850941500 -0600
++++ src/bash-4.3/builtins/set.def 2015-06-02 22:22:59.760951100 -0600
+@@ -56,6 +56,13 @@ extern int dont_save_function_defs;
+ #if defined (READLINE)
+ extern int no_line_editing;
+ #endif /* READLINE */
++#if __CYGWIN__
++extern int igncr;
++static int set_minus_o_option_maybe (int, const char *, int);
++# define INTERACTIVE_ONLY ,1
++#else /* ! __CYGWIN__ */
++# define INTERACTIVE_ONLY
++#endif
+
+ $BUILTIN set
+ $FUNCTION set_builtin
+@@ -92,6 +99,9 @@ Options:
+ #if defined (HISTORY)
+ history enable command history
+ #endif
++#if __CYGWIN__
++ igncr on cygwin, ignore \r in line endings
++#endif
+ ignoreeof the shell will not exit upon reading EOF
+ interactive-comments
+ allow comments to appear in interactive commands
+@@ -188,29 +198,41 @@ const struct {
+ int *variable;
+ setopt_set_func_t *set_func;
+ setopt_get_func_t *get_func;
++#if __CYGWIN__
++ /* Cygwin users have taken to exporting SHELLOPTS for the
++ cygwin-specific igncr. As a result, we need to make sure
++ SHELLOPTS parsing does not turn on interactive options when
++ exported from an interactive shell, but parsed in a
++ non-interactive setting, since some interactive options violate
++ POSIX /bin/sh rules. */
++ int interactive_only;
++#endif /* __CYGWIN__ */
+ } o_options[] = {
+ { "allexport", 'a', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ #if defined (BRACE_EXPANSION)
+ { "braceexpand",'B', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ #endif
+ #if defined (READLINE)
+- { "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode },
++ { "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode
INTERACTIVE_ONLY},
+ #endif
+ { "errexit", 'e', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ { "errtrace", 'E', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ { "functrace", 'T', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ { "hashall", 'h', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ #if defined (BANG_HISTORY)
+- { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
++ { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL INTERACTIVE_ONLY},
+ #endif /* BANG_HISTORY */
+ #if defined (HISTORY)
+- { "history", '\0', &enable_history_list, bash_set_history,
(setopt_get_func_t *)NULL },
++ { "history", '\0', &enable_history_list, bash_set_history,
(setopt_get_func_t *)NULL INTERACTIVE_ONLY},
++#endif
++#if __CYGWIN__
++ { "igncr", '\0', &igncr, NULL, (setopt_get_func_t *)NULL },
+ #endif
+ { "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL },
+ { "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t
*)NULL, (setopt_get_func_t *)NULL },
+ { "keyword", 'k', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ #if defined (JOB_CONTROL)
+- { "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
++ { "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL INTERACTIVE_ONLY},
+ #endif
+ { "noclobber", 'C', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ { "noexec", 'n', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+@@ -229,7 +251,7 @@ const struct {
+ { "privileged", 'p', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ { "verbose", 'v', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ #if defined (READLINE)
+- { "vi", '\0', (int *)NULL, set_edit_mode, get_edit_mode },
++ { "vi", '\0', (int *)NULL, set_edit_mode, get_edit_mode
INTERACTIVE_ONLY},
+ #endif
+ { "xtrace", 'x', (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+ {(char *)NULL, 0 , (int *)NULL, (setopt_set_func_t *)NULL,
(setopt_get_func_t *)NULL },
+@@ -416,6 +438,15 @@ int
+ set_minus_o_option (on_or_off, option_name)
+ int on_or_off;
+ char *option_name;
++#if __CYGWIN__
++{
++ /* See cygwin comments above. */
++ return set_minus_o_option_maybe (on_or_off, option_name, 0);
++}
++static int
++set_minus_o_option_maybe (int on_or_off, const char *option_name,
++ int avoid_interactive)
++#endif /* __CYGWIN__ */
+ {
+ register int i;
+
+@@ -423,6 +454,10 @@ set_minus_o_option (on_or_off, option_na
+ {
+ if (STREQ (option_name, o_options[i].name))
+ {
++#if __CYGWIN__
++ if (o_options[i].interactive_only && avoid_interactive)
++ return EXECUTION_SUCCESS;
++#endif /* __CYGWIN__ */
+ if (o_options[i].letter == 0)
+ {
+ SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
+@@ -548,7 +583,11 @@ parse_shellopts (value)
+ vptr = 0;
+ while (vname = extract_colon_unit (value, &vptr))
+ {
++#if __CYGWIN__
++ set_minus_o_option_maybe (FLAG_ON, vname, !interactive_shell);
++#else /* !__CYGWIN__ */
+ set_minus_o_option (FLAG_ON, vname);
++#endif
+ free (vname);
+ }
+ }
+--- origsrc/bash-4.3/builtins/shopt.def 2013-02-27 07:43:20.000000000
-0700
++++ src/bash-4.3/builtins/shopt.def 2015-06-02 22:22:59.760951100 -0600
+@@ -91,6 +91,11 @@ extern int glob_star;
+ extern int glob_asciirange;
+ extern int lastpipe_opt;
+
++#if __CYGWIN__
++extern int completion_strip_exe;
++#endif
++
++
+ #if defined (EXTENDED_GLOB)
+ extern int extended_glob;
+ #endif
+@@ -161,6 +166,9 @@ static struct {
+ { "compat40", &shopt_compat40, set_compatibility_level },
+ { "compat41", &shopt_compat41, set_compatibility_level },
+ { "compat42", &shopt_compat42, set_compatibility_level },
++#if __CYGWIN__
++ { "completion_strip_exe", &completion_strip_exe, NULL },
++#endif
+ #if defined (READLINE)
+ { "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
+ { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
+--- origsrc/bash-4.3/doc/bash.1 2014-02-06 07:03:52.000000000 -0700
++++ src/bash-4.3/doc/bash.1 2015-06-02 22:22:59.760951100 -0600
+@@ -1658,6 +1658,14 @@ subsequently reset.
+ Expands to the effective user ID of the current user, initialized at
+ shell startup. This variable is readonly.
+ .TP
++.B EXECIGNORE
++A colon-separated list of extended glob (see \fBPattern Matching\fP)
++patterns. Files with full paths matching one of these patterns are
++not considered executable for the purposes of completion and PATH
++searching, but the \fB[\fP, \fB[[\fP, and \fBtest\fP builtins are not
++affected. Use this variable to deal with systems that set the
++executable bit on files that are not actually executable.
++.TP
+ .B FUNCNAME
+ An array variable containing the names of all shell functions
+ currently in the execution call stack.
+@@ -3308,6 +3316,10 @@ the character
+ .B ``.''
+ at the start of a name or immediately following a slash
+ must be matched explicitly, unless the shell option
++.B completion_strip_exe
++If set, whenever bash sees `foo.exe' during completion, it checks if
++`foo' is the same file and strips the suffix.
++.TP 8
+ .B dotglob
+ is set.
+ When matching a pathname, the slash character must always be
+--- origsrc/bash-4.3/doc/bashref.texi 2014-02-22 11:20:36.000000000 -0700
++++ src/bash-4.3/doc/bashref.texi 2015-06-02 22:22:59.776306300 -0600
+@@ -4992,6 +4992,10 @@ filenames.
+ This variable is set by default, which is the default Bash behavior in
+ versions through 4.2.
+
++@item completion_strip_exe
++If set, whenever bash sees `foo.exe' during completion, it checks if
++`foo' is the same file and strips the suffix.
++
+ @item direxpand
+ If set, Bash
+ replaces directory names with the results of word expansion when performing
+@@ -5578,6 +5582,14 @@ Similar to @code{BASH_ENV}; used when th
+ The numeric effective user id of the current user. This variable
+ is readonly.
+
++@item EXECIGNORE
++A colon-separated list of extended glob ((@pxref{Pattern Matching})
++patterns. Files with full paths matching one of these patterns are
++not considered executable for the purposes of completion and PATH
++searching, but the @code{[}, @code{[[}, and @code{test} builtins are
++not affected. Use this variable to deal with systems that set the
++executable bit on files that are not actually executable.
++
+ @item FCEDIT
+ The editor used as a default by the @option{-e} option to the @code{fc}
+ builtin command.
+--- origsrc/bash-4.3/execute_cmd.c 2015-06-01 22:41:57.242554200 -0600
++++ src/bash-4.3/execute_cmd.c 2015-06-02 22:22:59.776306300 -0600
+@@ -58,6 +58,7 @@ extern int errno;
+ #endif
+
+ #define NEED_FPURGE_DECL
++#define NEED_SH_SETLINEBUF_DECL /* used in externs.h */
+
+ #include "bashansi.h"
+ #include "bashintl.h"
+--- origsrc/bash-4.3/expr.c 2014-01-03 06:55:00.000000000 -0700
++++ src/bash-4.3/expr.c 2015-06-02 22:22:59.776306300 -0600
+@@ -83,6 +83,7 @@
+
+ #include "shell.h"
+ #include "typemax.h" /* INTMAX_MAX, INTMAX_MIN */
++#define exp2 exp2_
+
+ /* Because of the $((...)) construct, expressions may include newlines.
+ Here is a macro which accepts newlines, tabs and spaces as whitespace. */
+--- origsrc/bash-4.3/findcmd.c 2012-10-15 05:45:04.000000000 -0600
++++ src/bash-4.3/findcmd.c 2015-06-02 22:22:59.776306300 -0600
+@@ -48,6 +48,8 @@
+ extern int errno;
+ #endif
+
++#include <glob/strmatch.h>
++
+ extern int posixly_correct;
+ extern int last_command_exit_value;
+
+@@ -77,6 +79,38 @@ int check_hashed_filenames;
+ containing the file of interest. */
+ int dot_found_in_search = 0;
+
++static struct ignorevar execignore =
++{
++ "EXECIGNORE",
++ (struct ign *)0,
++ 0,
++ (char *)0,
++ (sh_iv_item_func_t *)0,
++};
++
++void
++setup_exec_ignore (char *varname)
++{
++ setup_ignore_patterns (&execignore);
++}
++
++/* Return whether we should never consider file executable
++ * even if the system tells us it is. */
++static int
++is_on_exec_blacklist (char *name)
++{
++ struct ign *p;
++ int flags = FNM_EXTMATCH | FNM_CASEFOLD;
++
++ for (p = execignore.ignores; p && p->val; p++)
++ {
++ if (strmatch (p->val, (char *)name, flags) != FNM_NOMATCH)
++ return (1);
++ }
++
++ return (0);
++}
++
+ /* Return some flags based on information about this file.
+ The EXISTS bit is non-zero if the file is found.
+ The EXECABLE bit is non-zero the file is executble.
+@@ -104,7 +138,7 @@ file_status (name)
+ file access mechanisms into account. eaccess uses the effective
+ user and group IDs, not the real ones. We could use sh_eaccess,
+ but we don't want any special treatment for /dev/fd. */
+- if (eaccess (name, X_OK) == 0)
++ if (!is_on_exec_blacklist (name) && eaccess (name, X_OK) == 0)
+ r |= FS_EXECABLE;
+ if (eaccess (name, R_OK) == 0)
+ r |= FS_READABLE;
+--- origsrc/bash-4.3/findcmd.h 2012-01-14 16:56:25.000000000 -0700
++++ src/bash-4.3/findcmd.h 2015-06-02 22:22:59.776306300 -0600
+@@ -31,5 +31,6 @@ extern char *find_user_command __P((cons
+ extern char *find_path_file __P((const char *));
+ extern char *search_for_command __P((const char *, int));
+ extern char *user_command_matches __P((const char *, int, int));
++extern void setup_exec_ignore __P((char *));
+
+ #endif /* _FINDCMD_H_ */
+--- origsrc/bash-4.3/general.c 2014-01-30 14:46:15.000000000 -0700
++++ src/bash-4.3/general.c 2015-06-02 22:22:59.791899800 -0600
+@@ -44,6 +44,10 @@
+
+ #include <tilde/tilde.h>
+
++#ifdef __CYGWIN__
++# include <sys/cygwin.h>
++#endif
++
+ #if !defined (errno)
+ extern int errno;
+ #endif /* !errno */
+@@ -632,7 +636,8 @@ make_absolute (string, dot_path)
+ {
+ char pathbuf[PATH_MAX + 1];
+
+- cygwin_conv_to_full_posix_path (string, pathbuf);
++ cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE, string, pathbuf,
++ sizeof pathbuf);
+ result = savestring (pathbuf);
+ }
+ #else
+--- origsrc/bash-4.3/include/posixjmp.h 2012-12-23 20:20:50.000000000
-0700
++++ src/bash-4.3/include/posixjmp.h 2015-06-02 22:22:59.791899800 -0600
+@@ -27,13 +27,15 @@
+
+ #if defined (HAVE_POSIX_SIGSETJMP)
+ # define procenv_t sigjmp_buf
+-# if !defined (__OPENNT)
++# if !defined (__OPENNT) && !defined __CYGWIN__
+ # undef setjmp
+ # define setjmp(x) sigsetjmp((x), 1)
+-# define setjmp_nosigs(x) sigsetjmp((x), 0)
+ # undef longjmp
+ # define longjmp(x, n) siglongjmp((x), (n))
+-# endif /* !__OPENNT */
++# endif /* !__OPENNT && !__CYGWIN__ */
++# if !defined (__OPENNT)
++# define setjmp_nosigs(x) sigsetjmp((x), 0)
++# endif /* !__OPENNT */
+ #else
+ # define procenv_t jmp_buf
+ # define setjmp_nosigs setjmp
+--- origsrc/bash-4.3/input.c 2014-02-07 07:13:08.000000000 -0700
++++ src/bash-4.3/input.c 2015-06-02 22:22:59.791899800 -0600
+@@ -44,6 +44,10 @@
+ #include "quit.h"
+ #include "trap.h"
+
++#if __CYGWIN__
++int igncr;
++#endif
++
+ #if !defined (errno)
+ extern int errno;
+ #endif /* !errno */
+@@ -561,6 +565,19 @@ buffered_getchar ()
+ {
+ CHECK_TERMSIG;
+
++#if __CYGWIN__
++ /* shopt igncr means to discard carriage returns from input stream.
++ If cr is the only character in the buffer, then recurse to pick
++ up the next character; otherwise flatten the buffer. */
++ if (igncr)
++ {
++ int ch;
++ while ((ch = bufstream_getc (buffers[bash_input.location.buffered_fd]))
++ == '\r')
++ ;
++ return ch;
++ }
++#endif /* __CYGWIN__ */
+ #if !defined (DJGPP)
+ return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
+ #else
+--- origsrc/bash-4.3/lib/sh/pathphys.c 2013-05-28 13:33:58.000000000 -0600
++++ src/bash-4.3/lib/sh/pathphys.c 2015-06-02 22:22:59.823097800 -0600
+@@ -35,6 +35,7 @@
+ #include <stdio.h>
+ #include <chartypes.h>
+ #include <errno.h>
++#include <stdlib.h>
+
+ #include "shell.h"
+
+@@ -76,6 +77,10 @@ sh_physpath (path, flags)
+ char *path;
+ int flags;
+ {
++#if __CYGWIN__
++ /* realpath does this correctly without all the hassle */
++ return realpath (path, NULL);
++#else
+ char tbuf[PATH_MAX+1], linkbuf[PATH_MAX+1];
+ char *result, *p, *q, *qsave, *qbase, *workpath;
+ int double_slash_path, linklen, nlink;
+@@ -214,11 +219,7 @@ error:
+ {
+ q = result;
+ /* Duplicating some code here... */
+-#if defined (__CYGWIN__)
+- qbase = (ISALPHA((unsigned char)workpath[0]) && workpath[1] ==
':') ? workpath + 3 : workpath + 1;
+-#else
+ qbase = workpath + 1;
+-#endif
+ double_slash_path = DOUBLE_SLASH (workpath);
+ qbase += double_slash_path;
+
+@@ -249,6 +250,7 @@ error:
+ }
+
+ return (result);
++#endif /* ! __CYGWIN__ */
+ }
+
+ char *
+--- origsrc/bash-4.3/lib/sh/tmpfile.c 2013-12-18 15:50:13.000000000 -0700
++++ src/bash-4.3/lib/sh/tmpfile.c 2015-06-02 22:22:59.823097800 -0600
+@@ -96,7 +96,7 @@ get_tmpdir (flags)
+ if (tdir && (file_iswdir (tdir) == 0 || strlen (tdir) > PATH_MAX))
+ tdir = 0;
+
+- if (tdir == 0)
++ if (tdir == 0 || !file_iswdir (tdir))
+ tdir = get_sys_tmpdir ();
+
+ #if defined (HAVE_PATHCONF) && defined (_PC_NAME_MAX)
+@@ -118,14 +118,15 @@ sh_mktmpname (nameroot, flags)
+ struct stat sb;
+ int r, tdlen;
+
+- filename = (char *)xmalloc (PATH_MAX + 1);
++ filename = NULL;
+ tdir = get_tmpdir (flags);
+ tdlen = strlen (tdir);
+
+ lroot = nameroot ? nameroot : DEFAULT_NAMEROOT;
+
+ #ifdef USE_MKTEMP
+- sprintf (filename, "%s/%s.XXXXXX", tdir, lroot);
++ if (asprintf (&filename, "%s/%s.XXXXXX", tdir, lroot) < 0)
++ return NULL;
+ if (mktemp (filename) == 0)
+ {
+ free (filename);
+@@ -138,7 +139,9 @@ sh_mktmpname (nameroot, flags)
+ (unsigned long) time ((time_t *)0) ^
+ (unsigned long) dollar_dollar_pid ^
+ (unsigned long) ((flags & MT_USERANDOM) ? random () :
ntmpfiles++);
+- sprintf (filename, "%s/%s-%lu", tdir, lroot, filenum);
++ free (filename);
++ if (asprintf (&filename, "%s/%s-%lu", tdir, lroot, filenum) < 0)
++ return NULL;
+ if (tmpnamelen > 0 && tmpnamelen < 32)
+ filename[tdlen + 1 + tmpnamelen] = '\0';
+ # ifdef HAVE_LSTAT
+@@ -163,14 +166,19 @@ sh_mktmpfd (nameroot, flags, namep)
+ char *filename, *tdir, *lroot;
+ int fd, tdlen;
+
+- filename = (char *)xmalloc (PATH_MAX + 1);
++ filename = NULL;
+ tdir = get_tmpdir (flags);
+ tdlen = strlen (tdir);
+
+ lroot = nameroot ? nameroot : DEFAULT_NAMEROOT;
+
+ #ifdef USE_MKSTEMP
+- sprintf (filename, "%s/%s.XXXXXX", tdir, lroot);
++ if (asprintf (&filename, "%s/%s.XXXXXX", tdir, lroot) < 0)
++ {
++ if (namep)
++ *namep = NULL;
++ return -1;
++ }
+ fd = mkstemp (filename);
+ if (fd < 0 || namep == 0)
+ {
+@@ -187,7 +195,13 @@ sh_mktmpfd (nameroot, flags, namep)
+ (unsigned long) time ((time_t *)0) ^
+ (unsigned long) dollar_dollar_pid ^
+ (unsigned long) ((flags & MT_USERANDOM) ? random () :
ntmpfiles++);
+- sprintf (filename, "%s/%s-%lu", tdir, lroot, filenum);
++ free (filename);
++ if (asprintf (&filename, "%s/%s-%lu", tdir, lroot, filenum) < 0)
++ {
++ if (namep)
++ *namep = NULL;
++ return -1;
++ }
+ if (tmpnamelen > 0 && tmpnamelen < 32)
+ filename[tdlen + 1 + tmpnamelen] = '\0';
+ fd = open (filename, BASEOPENFLAGS | ((flags & MT_READWRITE) ? O_RDWR :
O_WRONLY), 0600);
+--- origsrc/bash-4.3/parse.y 2015-06-01 22:41:58.022560000 -0600
++++ src/bash-4.3/parse.y 2015-06-02 22:22:59.838697600 -0600
+@@ -1531,14 +1531,20 @@ yy_string_get ()
+ string = bash_input.location.string;
+
+ /* If the string doesn't exist, or is empty, EOF found. */
+- if (string && *string)
++ while (string && *string)
+ {
+ c = *string++;
+ bash_input.location.string = string;
++#if __CYGWIN__
++ {
++ extern int igncr;
++ if (igncr && c == '\r')
++ continue;
++ }
++#endif
+ return (c);
+ }
+- else
+- return (EOF);
++ return (EOF);
+ }
+
+ static int
+@@ -2305,7 +2311,7 @@ shell_getc (remove_quoted_newline)
+ if (n <= 2) /* we have to save 1 for the newline added
below */
+ {
+ if (truncating == 0)
+- internal_warning("shell_getc: shell_input_line_size (%zu)
exceeds SIZE_MAX (%llu): line truncated", shell_input_line_size, SIZE_MAX);
++ internal_warning("shell_getc: shell_input_line_size (%zu)
exceeds SIZE_MAX (%zu): line truncated", shell_input_line_size, SIZE_MAX);
+ shell_input_line[i] = '\0';
+ truncating = 1;
+ }
+@@ -3587,7 +3593,6 @@ parse_comsub (qc, open, close, lenp, fla
+
+ while (count)
+ {
+-comsub_readchar:
+ ch = shell_getc (qc != '\'' && (tflags & (LEX_INCOMMENT|LEX_PASSNEXT))
== 0);
+
+ if (ch == EOF)
+--- origsrc/bash-4.3/pathexp.h 2009-01-04 12:32:40.000000000 -0700
++++ src/bash-4.3/pathexp.h 2015-06-02 22:22:59.838697600 -0600
+@@ -86,7 +86,7 @@ struct ign {
+ typedef int sh_iv_item_func_t __P((struct ign *));
+
+ struct ignorevar {
+- char *varname; /* FIGNORE or GLOBIGNORE */
++ char *varname; /* FIGNORE or GLOBIGNORE or EXECIGNORE */
+ struct ign *ignores; /* Store the ignore strings here */
+ int num_ignores; /* How many are there? */
+ char *last_ignoreval; /* Last value of variable - cached for speed */
+--- origsrc/bash-4.3/subst.c 2015-06-01 22:41:57.367407300 -0600
++++ src/bash-4.3/subst.c 2015-06-02 22:22:59.838697600 -0600
+@@ -41,6 +41,7 @@
+ #include "posixstat.h"
+ #include "bashintl.h"
+
++#define NEED_SH_SETLINEBUF_DECL /* used in externs.h */
+ #include "shell.h"
+ #include "parser.h"
+ #include "flags.h"
+@@ -5268,6 +5269,13 @@ read_comsub (fd, quoted, rflag)
+ #endif
+ continue;
+ }
++#if __CYGWIN__
++ {
++ extern int igncr;
++ if (igncr && c == '\r')
++ continue;
++ }
++#endif /* __CYGWIN__ */
+
+ /* Add the character to ISTRING, possibly after resizing it. */
+ RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size,
DEFAULT_ARRAY_SIZE);
+@@ -5385,6 +5393,28 @@ command_substitute (string, quoted)
+ goto error_exit;
+ }
+
++#if __CYGWIN__
++ /* Passing a pipe through std fds can cause hangs when talking to a
++ non-cygwin child. Move it. */
++ if (fildes[0] < 3)
++ {
++ int fd = fcntl (fildes[0], F_DUPFD, 3);
++ close (fildes[0]);
++ fildes[0] = fd;
++ }
++ if (fildes[1] < 3)
++ {
++ int fd = fcntl (fildes[1], F_DUPFD, 3);
++ close (fildes[1]);
++ fildes[1] = fd;
++ }
++ if (fildes[0] < 0 || fildes[1] < 0)
++ {
++ sys_error (_("cannot make pipe for command substitution"));
++ goto error_exit;
++ }
++#endif /* __CYGWIN__ */
++
+ old_pid = last_made_pid;
+ #if defined (JOB_CONTROL)
+ old_pipeline_pgrp = pipeline_pgrp;
+--- origsrc/bash-4.3/variables.c 2015-06-01 22:41:57.928984100 -0600
++++ src/bash-4.3/variables.c 2015-06-02 22:22:59.854339600 -0600
+@@ -4681,6 +4681,8 @@ static struct name_and_function special_
+ { "COMP_WORDBREAKS", sv_comp_wordbreaks },
+ #endif
+
++ { "EXECIGNORE", sv_execignore },
++
+ { "FUNCNEST", sv_funcnest },
+
+ { "GLOBIGNORE", sv_globignore },
+@@ -4879,6 +4881,13 @@ sv_globignore (name)
+ setup_glob_ignore (name);
+ }
+
++/* What to do when EXECIGNORE changes. */
++void
++sv_execignore (char *name)
++{
++ setup_exec_ignore (name);
++}
++
+ #if defined (READLINE)
+ void
+ sv_comp_wordbreaks (name)
+@@ -4952,7 +4961,7 @@ sv_winsize (name)
+ /* Update the value of HOME in the export environment so tilde expansion will
+ work on cygwin. */
+ #if defined (__CYGWIN__)
+-sv_home (name)
++void sv_home (name)
+ char *name;
+ {
+ array_needs_making = 1;
+--- origsrc/bash-4.3/variables.h 2014-01-08 13:33:29.000000000 -0700
++++ src/bash-4.3/variables.h 2015-06-02 22:22:59.854339600 -0600
+@@ -372,6 +372,7 @@ extern void sv_ifs __P((char *));
+ extern void sv_path __P((char *));
+ extern void sv_mail __P((char *));
+ extern void sv_funcnest __P((char *));
++extern void sv_execignore __P((char *));
+ extern void sv_globignore __P((char *));
+ extern void sv_ignoreeof __P((char *));
+ extern void sv_strict_posix __P((char *));