diff -Naur bash-4.2-p42-orig/MANIFEST bash-4.2/MANIFEST --- bash-4.2-p42-orig/MANIFEST 2010-12-28 01:01:16 +0400 +++ bash-4.2/MANIFEST 2013-02-14 08:52:44 +0400 @@ -205,6 +205,7 @@ builtins/common.h f builtins/bashgetopt.h f cross-build/cygwin32.cache f +cross-build/msys32.cache f cross-build/x86-beos.cache f cross-build/opennt.cache f include/ansi_stdlib.h f diff -Naur bash-4.2-p42-orig/bashline.c bash-4.2/bashline.c --- bash-4.2-p42-orig/bashline.c 2013-02-14 08:46:35 +0400 +++ bash-4.2/bashline.c 2013-02-14 09:00:45 +0400 @@ -243,6 +243,11 @@ 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; @@ -457,11 +462,12 @@ kseq[0] = CTRL('J'); kseq[1] = '\0'; func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL); - if (func == rl_vi_editing_mode) + extern rl_command_func_t *_imp__rl_vi_editing_mode; + if (func == rl_vi_editing_mode || func == _imp__rl_vi_editing_mode) rl_unbind_key_in_map (CTRL('J'), emacs_meta_keymap); kseq[0] = CTRL('M'); func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL); - if (func == rl_vi_editing_mode) + if (func == rl_vi_editing_mode || func == _imp__rl_vi_editing_mode) rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap); #if defined (VI_MODE) rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap); @@ -480,7 +486,8 @@ kseq[0] = '~'; kseq[1] = '\0'; func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL); - if (func == 0 || func == rl_tilde_expand) + extern rl_command_func_t *_imp__rl_tilde_expand; + if (func == 0 || func == rl_tilde_expand || func == _imp__rl_tilde_expand) rl_bind_keyseq_in_map (kseq, bash_complete_username, emacs_meta_keymap); rl_bind_key_if_unbound_in_map ('~', bash_possible_username_completions, emacs_ctlx_keymap); @@ -503,7 +510,8 @@ kseq[0] = TAB; kseq[1] = '\0'; func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL); - if (func == 0 || func == rl_tab_insert) + extern rl_command_func_t *_imp__rl_tab_insert; + if (func == 0 || func == rl_tab_insert || func == _imp__rl_tab_insert) rl_bind_key_in_map (TAB, dynamic_complete_history, emacs_meta_keymap); /* Tell the completer that we want a crack first. */ @@ -1867,6 +1875,14 @@ /* If we have found a match, and it is an executable file or a directory name, return it. */ if (match && executable_or_directory (val)) +#elif __CYGWIN__ + /* executable_or_directory will do the right thing on //server, + but calling stat("//server") is an order of magnitude slower + than noting that readdir("//") only returns directories. */ + if (match && (searching_path ? executable_file (val) + : ((val[0] == '/' && val[1] == '/' + && ! strchr (&val[2], '/')) + || executable_or_directory (val)))) #else /* If we have found a match, and it is an executable file, return it. We don't return directory names when searching $PATH, since the @@ -1876,6 +1892,21 @@ if (match && (searching_path ? executable_file (val) : executable_or_directory (val))) #endif { +#if __CYGWIN__ + if (completion_strip_exe) + { + int 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 free (val); val = ""; /* So it won't be NULL. */ return (temp); @@ -2607,6 +2638,17 @@ 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); diff -Naur bash-4.2-p42-orig/builtins/set.def bash-4.2/builtins/set.def --- bash-4.2-p42-orig/builtins/set.def 2011-01-10 18:22:25 +0400 +++ bash-4.2/builtins/set.def 2013-02-14 09:00:52 +0400 @@ -56,6 +56,13 @@ #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 @@ #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 @@ -184,28 +194,40 @@ 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 }, - { "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}, { "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 }, { "noglob", 'f', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, @@ -223,7 +245,7 @@ { "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 }, @@ -410,6 +432,15 @@ 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; @@ -417,6 +448,10 @@ { 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); @@ -542,7 +577,11 @@ 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); } } diff -Naur bash-4.2-p42-orig/builtins/shopt.def bash-4.2/builtins/shopt.def --- bash-4.2-p42-orig/builtins/shopt.def 2013-02-14 08:46:35 +0400 +++ bash-4.2/builtins/shopt.def 2013-02-14 09:03:57 +0400 @@ -90,6 +90,10 @@ extern int glob_star; extern int lastpipe_opt; +#if __CYGWIN__ +extern int completion_strip_exe; +#endif + #if defined (EXTENDED_GLOB) extern int extended_glob; #endif @@ -157,6 +161,9 @@ { "compat32", &shopt_compat32, set_compatibility_level }, { "compat40", &shopt_compat40, set_compatibility_level }, { "compat41", &shopt_compat41, set_compatibility_level }, +#if __CYGWIN__ + { "completion_strip_exe", &completion_strip_exe, NULL }, +#endif #if defined (READLINE) { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand }, { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL }, diff -Naur bash-4.2-p42-orig/config-top.h bash-4.2/config-top.h --- bash-4.2-p42-orig/config-top.h 2009-12-23 00:29:39 +0400 +++ bash-4.2/config-top.h 2013-02-14 09:00:52 +0400 @@ -75,10 +75,10 @@ #define KSH_COMPATIBLE_SELECT /* System-wide .bashrc file for interactive shells. */ -/* #define SYS_BASHRC "/etc/bash.bashrc" */ +#define SYS_BASHRC "/etc/bash.bashrc" /* System-wide .bash_logout for login shells. */ -/* #define SYS_BASH_LOGOUT "/etc/bash.bash_logout" */ +#define SYS_BASH_LOGOUT "/etc/bash.bash_logout" /* Define this to make non-interactive shells begun with argv[0][0] == '-' run the startup files when not in posix mode. */ @@ -88,7 +88,7 @@ sshd and source the .bashrc if so (like the rshd behavior). This checks for the presence of SSH_CLIENT or SSH2_CLIENT in the initial environment, which can be fooled under certain not-uncommon circumstances. */ -/* #define SSH_SOURCE_BASHRC */ +#define SSH_SOURCE_BASHRC /* Define if you want the case-capitalizing operators (~[~]) and the `capcase' variable attribute (declare -c). */ diff -Naur bash-4.2-p42-orig/configure.in bash-4.2/configure.in --- bash-4.2-p42-orig/configure.in 2011-02-08 02:03:14 +0400 +++ bash-4.2/configure.in 2013-02-14 08:51:44 +0400 @@ -85,7 +85,7 @@ *-machten4) opt_bash_malloc=no ;; # MachTen 4.x *-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins *-beos*) opt_bash_malloc=no ;; # they say it's suitable -*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment +*-cygwin*|msys*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment *-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft esac @@ -411,6 +411,9 @@ *-cygwin*) cross_cache=${srcdir}/cross-build/cygwin32.cache ;; + *-msys*) + cross_cache=${srcdir}/cross-build/msys32.cache + ;; *-mingw*) cross_cache=${srcdir}/cross-build/cygwin32.cache ;; @@ -530,7 +533,7 @@ # section for OS versions that don't allow unresolved symbols # to be compiled into dynamic libraries. case "$host_os" in - cygwin*) TILDE_LIB= ;; + cygwin*|msys*) TILDE_LIB= ;; esac else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' @@ -1040,7 +1043,7 @@ *qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;; *qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;; powerux*) LOCAL_LIBS="-lgen" ;; -cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; +cygwin*|msys*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE -D_ALL_SOURCE" ;; esac diff -Naur bash-4.2-p42-orig/cross-build/msys32.cache bash-4.2/cross-build/msys32.cache --- bash-4.2-p42-orig/cross-build/msys32.cache 1970-01-01 04:00:00 +0400 +++ bash-4.2/cross-build/msys32.cache 2013-02-14 08:49:37 +0400 @@ -0,0 +1,251 @@ +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overriden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +ac_cv_build=${ac_cv_build='i686-pc-msys'} +ac_cv_build_alias=${ac_cv_build_alias='i686-pc-msys'} +ac_cv_c_bigendian=${ac_cv_c_bigendian='no'} +ac_cv_c_char_unsigned=${ac_cv_c_char_unsigned='no'} +ac_cv_c_compiler_gnu=${ac_cv_c_compiler_gnu='yes'} +ac_cv_c_const=${ac_cv_c_const='yes'} +ac_cv_c_inline=${ac_cv_c_inline='inline'} +ac_cv_c_long_double=${ac_cv_c_long_double='yes'} +ac_cv_c_stringize=${ac_cv_c_stringize='yes'} +ac_cv_decl_sys_siglist=${ac_cv_decl_sys_siglist='no'} +ac_cv_exeext=${ac_cv_exeext='.exe'} +ac_cv_func___setostype=${ac_cv_func___setostype='no'} +ac_cv_func__doprnt=${ac_cv_func__doprnt='no'} +ac_cv_func_alloca_works=${ac_cv_func_alloca_works='yes'} +ac_cv_func_asprintf=${ac_cv_func_asprintf='no'} +ac_cv_func_bcopy=${ac_cv_func_bcopy='yes'} +ac_cv_func_bindtextdomain=${ac_cv_func_bindtextdomain='no'} +ac_cv_func_bzero=${ac_cv_func_bzero='yes'} +ac_cv_func_confstr=${ac_cv_func_confstr='no'} +ac_cv_func_dlclose=${ac_cv_func_dlclose='yes'} +ac_cv_func_dlopen=${ac_cv_func_dlopen='yes'} +ac_cv_func_dlsym=${ac_cv_func_dlsym='yes'} +ac_cv_func_dup2=${ac_cv_func_dup2='yes'} +ac_cv_func_fnmatch=${ac_cv_func_fnmatch='no'} +ac_cv_func_getaddrinfo=${ac_cv_func_getaddrinfo='no'} +ac_cv_func_getcwd=${ac_cv_func_getcwd='yes'} +ac_cv_func_getdtablesize=${ac_cv_func_getdtablesize='yes'} +ac_cv_func_getgroups=${ac_cv_func_getgroups='yes'} +ac_cv_func_gethostbyname=${ac_cv_func_gethostbyname='yes'} +ac_cv_func_gethostname=${ac_cv_func_gethostname='yes'} +ac_cv_func_getpagesize=${ac_cv_func_getpagesize='yes'} +ac_cv_func_getpeername=${ac_cv_func_getpeername='yes'} +ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'} +ac_cv_func_getrlimit=${ac_cv_func_getrlimit='yes'} +ac_cv_func_getrusage=${ac_cv_func_getrusage='yes'} +ac_cv_func_getservbyname=${ac_cv_func_getservbyname='yes'} +ac_cv_func_gettext=${ac_cv_func_gettext='no'} +ac_cv_func_gettimeofday=${ac_cv_func_gettimeofday='yes'} +ac_cv_func_inet_aton=${ac_cv_func_inet_aton='yes'} +ac_cv_func_isascii=${ac_cv_func_isascii='yes'} +ac_cv_func_isblank=${ac_cv_func_isblank='no'} +ac_cv_func_isgraph=${ac_cv_func_isgraph='yes'} +ac_cv_func_isprint=${ac_cv_func_isprint='yes'} +ac_cv_func_isspace=${ac_cv_func_isspace='yes'} +ac_cv_func_isxdigit=${ac_cv_func_isxdigit='yes'} +ac_cv_func_killpg=${ac_cv_func_killpg='yes'} +ac_cv_func_lstat=${ac_cv_func_lstat='yes'} +ac_cv_func_memmove=${ac_cv_func_memmove='yes'} +ac_cv_func_mkfifo=${ac_cv_func_mkfifo='yes'} +ac_cv_func_pathconf=${ac_cv_func_pathconf='yes'} +ac_cv_func_putenv=${ac_cv_func_putenv='yes'} +ac_cv_func_readlink=${ac_cv_func_readlink='yes'} +ac_cv_func_rename=${ac_cv_func_rename='yes'} +ac_cv_func_sbrk=${ac_cv_func_sbrk='yes'} +ac_cv_func_select=${ac_cv_func_select='yes'} +ac_cv_func_setdtablesize=${ac_cv_func_setdtablesize='yes'} +ac_cv_func_setenv=${ac_cv_func_setenv='yes'} +ac_cv_func_setlinebuf=${ac_cv_func_setlinebuf='no'} +ac_cv_func_setlocale=${ac_cv_func_setlocale='yes'} +ac_cv_func_setvbuf=${ac_cv_func_setvbuf='yes'} +ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'} +ac_cv_func_siginterrupt=${ac_cv_func_siginterrupt='no'} +ac_cv_func_snprintf=${ac_cv_func_snprintf='yes'} +ac_cv_func_strcasecmp=${ac_cv_func_strcasecmp='yes'} +ac_cv_func_strchr=${ac_cv_func_strchr='yes'} +ac_cv_func_strcoll_works=${ac_cv_func_strcoll_works='yes'} +ac_cv_func_strerror=${ac_cv_func_strerror='yes'} +ac_cv_func_strpbrk=${ac_cv_func_strpbrk='yes'} +ac_cv_func_strtod=${ac_cv_func_strtod='yes'} +ac_cv_func_strtoimax=${ac_cv_func_strtoimax='no'} +ac_cv_func_strtol=${ac_cv_func_strtol='yes'} +ac_cv_func_strtoll=${ac_cv_func_strtoll='no'} +ac_cv_func_strtoul=${ac_cv_func_strtoul='yes'} +ac_cv_func_strtoull=${ac_cv_func_strtoull='no'} +ac_cv_func_strtoumax=${ac_cv_func_strtoumax='no'} +ac_cv_func_sysconf=${ac_cv_func_sysconf='yes'} +ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr='yes'} +ac_cv_func_tcgetpgrp=${ac_cv_func_tcgetpgrp='yes'} +ac_cv_func_textdomain=${ac_cv_func_textdomain='no'} +ac_cv_func_times=${ac_cv_func_times='yes'} +ac_cv_func_ttyname=${ac_cv_func_ttyname='yes'} +ac_cv_func_tzset=${ac_cv_func_tzset='yes'} +ac_cv_func_ulimit=${ac_cv_func_ulimit='no'} +ac_cv_func_uname=${ac_cv_func_uname='yes'} +ac_cv_func_vasprintf=${ac_cv_func_vasprintf='no'} +ac_cv_func_vprintf=${ac_cv_func_vprintf='yes'} +ac_cv_func_vsnprintf=${ac_cv_func_vsnprintf='yes'} +ac_cv_func_wait3=${ac_cv_func_wait3='yes'} +ac_cv_func_waitpid=${ac_cv_func_waitpid='yes'} +ac_cv_have_decl_confstr=${ac_cv_have_decl_confstr='no'} +ac_cv_have_decl_printf=${ac_cv_have_decl_printf='yes'} +ac_cv_have_decl_sbrk=${ac_cv_have_decl_sbrk='yes'} +ac_cv_have_decl_strsignal=${ac_cv_have_decl_strsignal='yes'} +ac_cv_have_decl_strtold=${ac_cv_have_decl_strtold='no'} +ac_cv_header_arpa_inet_h=${ac_cv_header_arpa_inet_h='yes'} +ac_cv_header_dirent_dirent_h=${ac_cv_header_dirent_dirent_h='yes'} +ac_cv_header_dlfcn_h=${ac_cv_header_dlfcn_h='yes'} +ac_cv_header_grp_h=${ac_cv_header_grp_h='yes'} +ac_cv_header_inttypes_h=${ac_cv_header_inttypes_h='no'} +ac_cv_header_libintl_h=${ac_cv_header_libintl_h='yes'} +ac_cv_header_limits_h=${ac_cv_header_limits_h='yes'} +ac_cv_header_locale_h=${ac_cv_header_locale_h='yes'} +ac_cv_header_memory_h=${ac_cv_header_memory_h='yes'} +ac_cv_header_minix_config_h=${ac_cv_header_minix_config_h='no'} +ac_cv_header_netdb_h=${ac_cv_header_netdb_h='yes'} +ac_cv_header_netinet_in_h=${ac_cv_header_netinet_in_h='yes'} +ac_cv_header_stat_broken=${ac_cv_header_stat_broken='no'} +ac_cv_header_stdarg_h=${ac_cv_header_stdarg_h='yes'} +ac_cv_header_stdc=${ac_cv_header_stdc='yes'} +ac_cv_header_stddef_h=${ac_cv_header_stddef_h='yes'} +ac_cv_header_stdint_h=${ac_cv_header_stdint_h='no'} +ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h='yes'} +ac_cv_header_string_h=${ac_cv_header_string_h='yes'} +ac_cv_header_strings_h=${ac_cv_header_strings_h='yes'} +ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h='yes'} +ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h='yes'} +ac_cv_header_sys_pte_h=${ac_cv_header_sys_pte_h='no'} +ac_cv_header_sys_ptem_h=${ac_cv_header_sys_ptem_h='no'} +ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h='yes'} +ac_cv_header_sys_select_h=${ac_cv_header_sys_select_h='yes'} +ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h='yes'} +ac_cv_header_sys_stat_h=${ac_cv_header_sys_stat_h='yes'} +ac_cv_header_sys_stream_h=${ac_cv_header_sys_stream_h='no'} +ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h='yes'} +ac_cv_header_sys_times_h=${ac_cv_header_sys_times_h='yes'} +ac_cv_header_sys_types_h=${ac_cv_header_sys_types_h='yes'} +ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h='yes'} +ac_cv_header_termcap_h=${ac_cv_header_termcap_h='yes'} +ac_cv_header_termio_h=${ac_cv_header_termio_h='yes'} +ac_cv_header_termios_h=${ac_cv_header_termios_h='yes'} +ac_cv_header_time=${ac_cv_header_time='yes'} +ac_cv_header_unistd_h=${ac_cv_header_unistd_h='yes'} +ac_cv_header_varargs_h=${ac_cv_header_varargs_h='yes'} +ac_cv_host=${ac_cv_host='i686-pc-msys'} +ac_cv_host_alias=${ac_cv_host_alias='i686-pc-msys'} +ac_cv_lib_dir_opendir=${ac_cv_lib_dir_opendir='no'} +ac_cv_lib_dl_dlopen=${ac_cv_lib_dl_dlopen='no'} +ac_cv_lib_intl_bindtextdomain=${ac_cv_lib_intl_bindtextdomain='yes'} +ac_cv_lib_termcap_tgetent=${ac_cv_lib_termcap_tgetent='yes'} +ac_cv_member_struct_stat_st_blocks=${ac_cv_member_struct_stat_st_blocks='yes'} +ac_cv_member_struct_termio_c_line=${ac_cv_member_struct_termio_c_line='yes'} +ac_cv_member_struct_termios_c_line=${ac_cv_member_struct_termios_c_line='yes'} +ac_cv_objext=${ac_cv_objext='o'} +ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'} +ac_cv_prog_AR=${ac_cv_prog_AR='ar'} +ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'} +ac_cv_prog_YACC=${ac_cv_prog_YACC='bison -y'} +ac_cv_prog_ac_ct_CC=${ac_cv_prog_ac_ct_CC='gcc'} +ac_cv_prog_ac_ct_RANLIB=${ac_cv_prog_ac_ct_RANLIB='ranlib'} +ac_cv_prog_cc_g=${ac_cv_prog_cc_g='yes'} +ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=''} +ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional='no'} +ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set='yes'} +ac_cv_sizeof_char=${ac_cv_sizeof_char='1'} +ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} +ac_cv_sizeof_double=${ac_cv_sizeof_double='8'} +ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} +ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} +ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long='8'} +ac_cv_sizeof_short=${ac_cv_sizeof_short='2'} +ac_cv_sys_file_offset_bits=${ac_cv_sys_file_offset_bits='no'} +ac_cv_sys_interpreter=${ac_cv_sys_interpreter='yes'} +ac_cv_sys_large_files=${ac_cv_sys_large_files='no'} +ac_cv_sys_largefile_CC=${ac_cv_sys_largefile_CC='no'} +ac_cv_sys_posix_termios=${ac_cv_sys_posix_termios='yes'} +ac_cv_sys_tiocgwinsz_in_termios_h=${ac_cv_sys_tiocgwinsz_in_termios_h='yes'} +ac_cv_type_bits16_t=${ac_cv_type_bits16_t='no'} +ac_cv_type_bits32_t=${ac_cv_type_bits32_t='no'} +ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'} +ac_cv_type_char=${ac_cv_type_char='yes'} +ac_cv_type_char_p=${ac_cv_type_char_p='yes'} +ac_cv_type_double=${ac_cv_type_double='yes'} +ac_cv_type_getgroups=${ac_cv_type_getgroups='gid_t'} +ac_cv_type_int=${ac_cv_type_int='yes'} +ac_cv_type_long=${ac_cv_type_long='yes'} +ac_cv_type_long_long=${ac_cv_type_long_long='yes'} +ac_cv_type_mode_t=${ac_cv_type_mode_t='yes'} +ac_cv_type_off_t=${ac_cv_type_off_t='yes'} +ac_cv_type_pid_t=${ac_cv_type_pid_t='yes'} +ac_cv_type_ptrdiff_t=${ac_cv_type_ptrdiff_t='yes'} +ac_cv_type_short=${ac_cv_type_short='yes'} +ac_cv_type_signal=${ac_cv_type_signal='void'} +ac_cv_type_size_t=${ac_cv_type_size_t='yes'} +ac_cv_type_ssize_t=${ac_cv_type_ssize_t='yes'} +ac_cv_type_time_t=${ac_cv_type_time_t='yes'} +ac_cv_type_u_bits16_t=${ac_cv_type_u_bits16_t='no'} +ac_cv_type_u_bits32_t=${ac_cv_type_u_bits32_t='no'} +ac_cv_type_u_int=${ac_cv_type_u_int='yes'} +ac_cv_type_u_long=${ac_cv_type_u_long='yes'} +ac_cv_type_uid_t=${ac_cv_type_uid_t='yes'} +ac_cv_working_alloca_h=${ac_cv_working_alloca_h='no'} + +bash_cv_decl_strtoimax=${bash_cv_decl_strtoimax='no'} +bash_cv_decl_strtol=${bash_cv_decl_strtol='yes'} +bash_cv_decl_strtoll=${bash_cv_decl_strtoll='no'} +bash_cv_decl_strtoul=${bash_cv_decl_strtoul='yes'} +bash_cv_decl_strtoull=${bash_cv_decl_strtoull='no'} +bash_cv_decl_strtoumax=${bash_cv_decl_strtoumax='no'} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'} +bash_cv_dev_fd=${bash_cv_dev_fd='absent'} +bash_cv_dev_stdin=${bash_cv_dev_stdin='absent'} +bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno='no'} +bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino='yes'} +bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} +bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl='no'} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='present'} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'} +bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'} +bash_cv_getpw_declared=${bash_cv_getpw_declared='yes'} +bash_cv_have_strsignal=${bash_cv_have_strsignal='yes'} +bash_cv_job_control_missing=${bash_cv_job_control_missing='present'} +bash_cv_mail_dir=${bash_cv_mail_dir='unknown'} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} +bash_cv_printf_a_format=${bash_cv_printf_a_format='no'} +bash_cv_signal_vintage=${bash_cv_signal_vintage='posix'} +bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types='no'} +bash_cv_struct_timeval=${bash_cv_struct_timeval='yes'} +bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header='termios_h'} +bash_cv_sys_errlist=${bash_cv_sys_errlist='no'} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='present'} +bash_cv_sys_siglist=${bash_cv_sys_siglist='no'} +bash_cv_termcap_lib=${bash_cv_termcap_lib='libtermcap'} +bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl='no'} +bash_cv_type_clock_t=${bash_cv_type_clock_t='yes'} +bash_cv_type_intmax_t=${bash_cv_type_intmax_t='no'} +bash_cv_type_long_long=${bash_cv_type_long_long='long long'} +bash_cv_type_quad_t=${bash_cv_type_quad_t='no'} +bash_cv_type_rlimit=${bash_cv_type_rlimit='rlim_t'} +bash_cv_type_sigset_t=${bash_cv_type_sigset_t='yes'} +bash_cv_type_socklen_t=${bash_cv_type_socklen_t='no'} +bash_cv_type_uintmax_t=${bash_cv_type_uintmax_t='no'} +bash_cv_type_unsigned_long_long=${bash_cv_type_unsigned_long_long='unsigned long long'} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'} +bash_cv_unusable_rtsigs=${bash_cv_unusable_rtsigs='no'} +bash_cv_void_sighandler=${bash_cv_void_sighandler='yes'} diff -Naur bash-4.2-p42-orig/doc/Makefile.in bash-4.2/doc/Makefile.in --- bash-4.2-p42-orig/doc/Makefile.in 2010-01-15 23:23:36 +0400 +++ bash-4.2/doc/Makefile.in 2013-02-14 09:00:53 +0400 @@ -170,7 +170,7 @@ $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi bash.info: bashref.info - ${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \ + ${SHELL} ${INFOPOST} < bashref.info > $@ ; \ bash.txt: bash.1 bash.ps: bash.1 @@ -226,9 +226,9 @@ -$(INSTALL_DATA) $(srcdir)/bash.1 $(DESTDIR)$(man1dir)/bash${man1ext} -$(INSTALL_DATA) $(srcdir)/bashbug.1 $(DESTDIR)$(man1dir)/bashbug${man1ext} # uncomment the next lines to install the builtins man page -# sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/var/tmp}/builtins.1 -# -$(INSTALL_DATA) $${TMPDIR:-/var/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext} -# -$(RM) $${TMPDIR:-/var/tmp}/builtins.1 + sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/tmp}/builtins.1 + -$(INSTALL_DATA) $${TMPDIR:-/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext} + -$(RM) $${TMPDIR:-/tmp}/builtins.1 -if test -f bash.info; then d=.; else d=$(srcdir); fi; \ $(INSTALL_DATA) $$d/bash.info $(DESTDIR)$(infodir)/bash.info # run install-info if it is present to update the info directory diff -Naur bash-4.2-p42-orig/doc/bash.1 bash-4.2/doc/bash.1 --- bash-4.2-p42-orig/doc/bash.1 2013-02-14 08:46:35 +0400 +++ bash-4.2/doc/bash.1 2013-02-14 09:00:53 +0400 @@ -1592,6 +1592,14 @@ 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. @@ -8964,6 +8972,10 @@ attempts spelling correction on directory names during word completion if the directory name initially supplied does not exist. .TP 8 +.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 If set, .B bash diff -Naur bash-4.2-p42-orig/doc/bashref.texi bash-4.2/doc/bashref.texi --- bash-4.2-p42-orig/doc/bashref.texi 2013-02-14 08:46:35 +0400 +++ bash-4.2/doc/bashref.texi 2013-02-14 09:00:53 +0400 @@ -4542,6 +4542,10 @@ buffer. If not set, Bash attempts to preserve what the user typed. +@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 dirspell If set, Bash attempts spelling correction on directory names during word completion @@ -5087,6 +5091,14 @@ 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. diff -Naur bash-4.2-p42-orig/doc/builtins.1 bash-4.2/doc/builtins.1 --- bash-4.2-p42-orig/doc/builtins.1 2008-08-12 17:24:40 +0400 +++ bash-4.2/doc/builtins.1 2013-02-14 09:00:53 +0400 @@ -12,6 +12,6 @@ ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1) .SH BASH BUILTIN COMMANDS .nr zZ 1 -.so bash.1 +.so man1/bash.1 .SH SEE ALSO bash(1), sh(1) diff -Naur bash-4.2-p42-orig/examples/complete/bash_completion bash-4.2/examples/complete/bash_completion --- bash-4.2-p42-orig/examples/complete/bash_completion 2008-08-23 05:20:17 +0400 +++ bash-4.2/examples/complete/bash_completion 2013-02-14 08:55:37 +0400 @@ -48,6 +48,7 @@ UNAME=$( uname -s ) # strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin) UNAME=${UNAME/CYGWIN_*/Cygwin} +UNAME=${UNAME/MSYS_*/Msys} RELEASE=$( uname -r ) # features supported by bash 2.05 and higher @@ -817,7 +818,7 @@ # [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \ -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \ - -o $UNAME = OpenBSD ] && + -o $UNAME = Msys -o $UNAME = OpenBSD ] && _man() { local cur prev sect manpath UNAME @@ -837,8 +838,9 @@ UNAME=$( uname -s ) # strip OS type and version under Cygwin UNAME=${UNAME/CYGWIN_*/Cygwin} + UNAME=${UNAME/MSYS_*/Msys} if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \ - -o $UNAME = Cygwin ]; then + -o $UNAME = Cygwin -o $UNAME = Msys ]; then manpath=$( manpath 2>/dev/null || command man --path ) else manpath=$MANPATH @@ -873,7 +875,7 @@ } [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \ -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \ - -o $UNAME = OpenBSD ] && \ + -o $UNAME = Msys -o $UNAME = OpenBSD ] && \ complete -F _man $filenames man apropos whatis # renice(8) completion @@ -4264,7 +4266,7 @@ fi } && complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc -[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \ +[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin -o $UNAME = Msys ] && \ [ -n "${have:-}" ] && complete $filenames -F _gcc cc # Linux cardctl(8) completion diff -Naur bash-4.2-p42-orig/execute_cmd.c bash-4.2/execute_cmd.c --- bash-4.2-p42-orig/execute_cmd.c 2013-02-14 08:46:35 +0400 +++ bash-4.2/execute_cmd.c 2013-02-14 09:00:53 +0400 @@ -5047,6 +5047,13 @@ internal_error (_("%s: cannot execute binary file"), command); return (EX_BINARY_FILE); } +#if __CYGWIN__ + extern int sh_setlinebuf (FILE *); + /* Let stdio know that fd may have changed from text to binary. */ + freopen (NULL, "w", stdout); + /* Bash builtins (foolishly) rely on line-buffering. */ + sh_setlinebuf (stdout); +#endif /* __CYGWIN__ */ } /* We have committed to attempting to execute the contents of this file diff -Naur bash-4.2-p42-orig/findcmd.c bash-4.2/findcmd.c --- bash-4.2-p42-orig/findcmd.c 2010-10-07 01:38:40 +0400 +++ bash-4.2/findcmd.c 2013-02-14 09:00:53 +0400 @@ -48,6 +48,8 @@ extern int errno; #endif +#include + extern int posixly_correct; /* Static functions defined and used in this file. */ @@ -76,6 +78,38 @@ 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. @@ -103,7 +137,7 @@ 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; diff -Naur bash-4.2-p42-orig/findcmd.h bash-4.2/findcmd.h --- bash-4.2-p42-orig/findcmd.h 2009-01-04 23:32:29 +0400 +++ bash-4.2/findcmd.h 2013-02-14 09:00:53 +0400 @@ -31,5 +31,6 @@ extern char *find_path_file __P((const char *)); extern char *search_for_command __P((const char *)); extern char *user_command_matches __P((const char *, int, int)); +extern void setup_exec_ignore __P((char *)); #endif /* _FINDCMD_H_ */ diff -Naur bash-4.2-p42-orig/input.c bash-4.2/input.c --- bash-4.2-p42-orig/input.c 2011-01-03 00:58:57 +0400 +++ bash-4.2/input.c 2013-02-14 09:00:53 +0400 @@ -43,6 +43,10 @@ #include "externs.h" #include "quit.h" +#if __CYGWIN__ +int igncr; +#endif /* __CYGWIN__ */ + #if !defined (errno) extern int errno; #endif /* !errno */ @@ -550,6 +554,19 @@ { 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 diff -Naur bash-4.2-p42-orig/lib/sh/pathcanon.c bash-4.2/lib/sh/pathcanon.c --- bash-4.2-p42-orig/lib/sh/pathcanon.c 2008-08-12 22:01:37 +0400 +++ bash-4.2/lib/sh/pathcanon.c 2013-02-14 09:00:53 +0400 @@ -194,6 +194,8 @@ *q++ = DIRSEP; while (*p && (ISDIRSEP(*p) == 0)) *q++ = *p++; + } + } /* Check here for a valid directory with _path_isdir. */ if (flags & PATH_CHECKEXISTS) { @@ -211,8 +213,7 @@ } *q = c; } - } - } + /* Empty string is really ``.'' or `/', depending on what we started with. */ if (q == result) diff -Naur bash-4.2-p42-orig/lib/sh/pathphys.c bash-4.2/lib/sh/pathphys.c --- bash-4.2-p42-orig/lib/sh/pathphys.c 2008-08-12 22:01:23 +0400 +++ bash-4.2/lib/sh/pathphys.c 2013-02-14 09:00:53 +0400 @@ -35,6 +35,7 @@ #include #include #include +#include #include "shell.h" @@ -76,6 +77,10 @@ char *path; int flags; { +#if __CYGWIN__ + /* realpath does this right 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; @@ -249,6 +254,7 @@ } return (result); +#endif /* !__CYGWIN__ */ } char * diff -Naur bash-4.2-p42-orig/lib/sh/tmpfile.c bash-4.2/lib/sh/tmpfile.c --- bash-4.2-p42-orig/lib/sh/tmpfile.c 2011-01-03 00:34:07 +0400 +++ bash-4.2/lib/sh/tmpfile.c 2013-02-14 09:33:02 +0400 @@ -94,7 +94,7 @@ 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) @@ -116,14 +116,15 @@ 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); @@ -136,7 +137,9 @@ (unsigned long) time ((time_t *)0) ^ (unsigned long) dollar_dollar_pid ^ (unsigned long) ((flags & MT_USERANDOM) ? get_random_number () : 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 @@ -161,14 +164,19 @@ 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) { @@ -185,7 +193,13 @@ (unsigned long) time ((time_t *)0) ^ (unsigned long) dollar_dollar_pid ^ (unsigned long) ((flags & MT_USERANDOM) ? get_random_number () : 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); diff -Naur bash-4.2-p42-orig/parse.y bash-4.2/parse.y --- bash-4.2-p42-orig/parse.y 2013-02-14 08:46:36 +0400 +++ bash-4.2/parse.y 2013-02-14 09:00:56 +0400 @@ -1526,14 +1526,20 @@ 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 /* __CYGWIN__ */ return (c); } - else - return (EOF); + return (EOF); } static int diff -Naur bash-4.2-p42-orig/pathexp.h bash-4.2/pathexp.h --- bash-4.2-p42-orig/pathexp.h 2009-01-04 23:32:40 +0400 +++ bash-4.2/pathexp.h 2013-02-14 09:00:56 +0400 @@ -86,7 +86,7 @@ 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 */ diff -Naur bash-4.2-p42-orig/shell.c bash-4.2/shell.c --- bash-4.2-p42-orig/shell.c 2011-01-03 01:04:51 +0400 +++ bash-4.2/shell.c 2013-02-14 09:00:56 +0400 @@ -330,7 +330,10 @@ struct stat sb; if (stat ("/tmp", &sb) < 0) - internal_warning (_("could not find /tmp, please create!")); + { + if (mkdir ("/tmp", S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX) != 0) + internal_warning (_("could not find /tmp, please create!")); + } else { if (S_ISDIR (sb.st_mode) == 0) diff -Naur bash-4.2-p42-orig/subst.c bash-4.2/subst.c --- bash-4.2-p42-orig/subst.c 2013-02-14 08:46:36 +0400 +++ bash-4.2/subst.c 2013-02-14 09:43:10 +0400 @@ -5183,7 +5183,13 @@ #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); @@ -5299,6 +5305,27 @@ sys_error (_("cannot make pipe for command substitution")); 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) diff -Naur bash-4.2-p42-orig/support/config.guess bash-4.2/support/config.guess --- bash-4.2-p42-orig/support/config.guess 2009-01-04 23:41:33 +0400 +++ bash-4.2/support/config.guess 2013-02-14 08:58:38 +0400 @@ -781,6 +781,9 @@ i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; @@ -818,6 +821,9 @@ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; + amd64:MSYS*:*:* | x86_64:MSYS*:*:*) + echo x86_64-unknown-msys + exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; diff -Naur bash-4.2-p42-orig/support/config.rpath bash-4.2/support/config.rpath --- bash-4.2-p42-orig/support/config.rpath 2008-08-13 16:34:20 +0400 +++ bash-4.2/support/config.rpath 2013-02-14 08:59:11 +0400 @@ -108,7 +108,7 @@ hardcode_minus_L=no case "$host_os" in - cygwin* | mingw* | pw32*) + cygwin* | msys* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. @@ -148,7 +148,7 @@ ld_shlibs=no fi ;; - cygwin* | mingw* | pw32*) + cygwin* | msys* | mingw* | pw32*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -267,7 +267,7 @@ ;; bsdi4*) ;; - cygwin* | mingw* | pw32*) + cygwin* | msys* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -439,7 +439,7 @@ ;; bsdi4*) ;; - cygwin* | mingw* | pw32*) + cygwin* | msys* | mingw* | pw32*) shrext=.dll ;; darwin* | rhapsody*) diff -Naur bash-4.2-p42-orig/support/config.sub bash-4.2/support/config.sub --- bash-4.2-p42-orig/support/config.sub 2009-11-19 22:43:37 +0400 +++ bash-4.2/support/config.sub 2013-02-14 08:59:32 +0400 @@ -1256,7 +1256,7 @@ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ diff -Naur bash-4.2-p42-orig/support/shobj-conf bash-4.2/support/shobj-conf --- bash-4.2-p42-orig/support/shobj-conf 2013-02-14 08:46:34 +0400 +++ bash-4.2/support/shobj-conf 2013-02-14 09:00:04 +0400 @@ -519,6 +519,23 @@ SHLIB_DLLVERSION="$DLLVERSION" fi ;; +msys*) + SHOBJ_LD='$(CC)' + SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a' + SHLIB_LIBPREF='msys-' + SHLIB_LIBSUFF='dll' + SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)' + SHLIB_LIBS='$(TERMCAP_LIB)' + + SHLIB_DOT= + # For official cygwin releases, DLLVERSION will be defined in the + # environment of configure, and will be incremented any time the API + # changes in a non-backwards compatible manner. Otherwise, it is just + # SHLIB_MAJOR. + if [ -n "$DLLVERSION" ] ; then + SHLIB_DLLVERSION="$DLLVERSION" + fi + ;; mingw*) SHOBJ_LD='$(CC)' diff -Naur bash-4.2-p42-orig/variables.c bash-4.2/variables.c --- bash-4.2-p42-orig/variables.c 2013-02-14 08:46:33 +0400 +++ bash-4.2/variables.c 2013-02-14 09:00:59 +0400 @@ -4178,6 +4178,8 @@ { "FUNCNEST", sv_funcnest }, + { "EXECIGNORE", sv_execignore }, + { "GLOBIGNORE", sv_globignore }, #if defined (HISTORY) @@ -4374,6 +4376,13 @@ 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) diff -Naur bash-4.2-p42-orig/variables.h bash-4.2/variables.h --- bash-4.2-p42-orig/variables.h 2013-02-14 08:46:33 +0400 +++ bash-4.2/variables.h 2013-02-14 09:00:59 +0400 @@ -356,6 +356,7 @@ extern void sv_mail __P((char *)); extern void sv_funcnest __P((char *)); extern void sv_globignore __P((char *)); +extern void sv_execignore __P((char *)); extern void sv_ignoreeof __P((char *)); extern void sv_strict_posix __P((char *)); extern void sv_optind __P((char *));