--- bash-5.1/configure.ac.orig	2020-12-04 15:04:55.000000000 +0100
+++ bash-5.1/configure.ac	2020-12-19 16:30:53.432216400 +0100
@@ -76,7 +76,7 @@
 # These need additional investigation
 sparc-linux*)	opt_bash_malloc=no ;;	# sparc running linux; requires ELF
 *-aix*)		opt_bash_malloc=no ;;	# AIX machines
-*-cygwin*)	opt_bash_malloc=no ;;	# Cygnus's CYGWIN environment
+*-cygwin*|msys*)	opt_bash_malloc=no ;;	# Cygnus's CYGWIN environment
 # These lack a working sbrk(2)
 aarch64-freebsd*)	opt_bash_malloc=no ;;
 riscv*-freebsd*)	opt_bash_malloc=no ;;
@@ -446,6 +446,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
 	;;
@@ -580,7 +583,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'
@@ -1168,7 +1171,7 @@
 *qnx[[67]]*)	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 -DRECYCLES_PIDS" ;;
 *openstep*)	LOCAL_CFLAGS="-D__APPLE_CC__" ;;
 esac
diff -Naur a/cross-build/msys32.cache b/cross-build/msys32.cache
--- a/cross-build/msys32.cache	1970-01-01 03:00:00.000000000 +0300
+++ b/cross-build/msys32.cache	2014-03-13 16:36:06.389000000 +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 a/examples/complete/bash_completion b/examples/complete/bash_completion
--- a/examples/complete/bash_completion	2008-08-23 05:20:17.000000000 +0400
+++ b/examples/complete/bash_completion	2014-03-13 16:36:06.404600000 +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 a/MANIFEST b/MANIFEST
--- a/MANIFEST	2014-02-25 18:31:30.000000000 +0400
+++ b/MANIFEST	2014-03-13 16:36:06.404600000 +0400
@@ -207,6 +207,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
--- bash-5.1/support/config.guess.orig	2020-11-18 20:38:39.000000000 +0100
+++ bash-5.1/support/config.guess	2020-12-19 16:27:26.381313600 +0100
@@ -876,6 +876,9 @@
     *:MINGW64*:*)
 	echo "$UNAME_MACHINE"-pc-mingw64
 	exit ;;
+    i*:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
     *:MINGW*:*)
 	echo "$UNAME_MACHINE"-pc-mingw32
 	exit ;;
@@ -903,6 +906,9 @@
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	echo x86_64-pc-cygwin
 	exit ;;
+    amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
+	echo x86_64-pc-msys
+	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
 	exit ;;
--- bash-5.1/support/config.rpath.orig	2020-12-19 16:21:12.539354600 +0100
+++ bash-5.1/support/config.rpath	2020-12-19 16:22:59.203761400 +0100
@@ -57,7 +57,7 @@
     aix*)
       wl='-Wl,'
       ;;
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       ;;
     hpux9* | hpux10* | hpux11*)
       wl='-Wl,'
@@ -149,7 +149,7 @@
 hardcode_minus_L=no
 
 case "$host_os" in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # 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++.
@@ -198,7 +198,7 @@
         ld_shlibs=no
       fi
       ;;
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # hardcode_libdir_flag_spec is actually meaningless, as there is
       # no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -348,7 +348,7 @@
       ;;
     bsdi[45]*)
       ;;
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -533,7 +533,7 @@
   bsdi[45]*)
     library_names_spec='$libname$shrext'
     ;;
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     shrext=.dll
     library_names_spec='$libname.dll.a $libname.lib'
     ;;
diff -Naur a/support/shobj-conf b/support/shobj-conf
--- a/support/shobj-conf	2014-02-24 06:06:29.000000000 +0400
+++ b/support/shobj-conf	2014-03-13 16:36:06.451400000 +0400
@@ -534,6 +534,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)'
