patch 8.2.3079: Powershell core not supported by default

Problem:    Powershell core not supported by default.
Solution:   Set option defaults for "pwsh". (Mike Williams, closes #8481)
diff --git a/src/fileio.c b/src/fileio.c
index 55012bf..bd4038c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5222,6 +5222,7 @@
     WCHAR	*chartab = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     char_u	*retval;
     char_u	*p;
+    char_u	*shname;
     long	i;
 
     wcscpy(itmp, L"");
@@ -5247,8 +5248,10 @@
     // "sh".  NOTE: This also checks 'shellcmdflag' to help those people who
     // didn't set 'shellslash' but only if not using PowerShell.
     retval = utf16_to_enc(itmp, NULL);
-    if ((strstr((char *)gettail(p_sh), "powershell") == NULL
-						&& *p_shcf == '-') || p_ssl)
+    shname = gettail(p_sh);
+    if ((*p_shcf == '-' && !(strstr((char *)shname, "powershell") != NULL
+			     || strstr((char *)shname, "pwsh") != NULL ))
+								    || p_ssl)
 	for (p = retval; *p; ++p)
 	    if (*p == '\\')
 		*p = '/';
diff --git a/src/misc2.c b/src/misc2.c
index 6bbfbd7..ead1e63 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1414,8 +1414,9 @@
     char_u	*escaped_string;
     int		l;
     int		csh_like;
-# ifdef MSWIN
+    char_u	*shname;
     int		powershell;
+# ifdef MSWIN
     int		double_quotes;
 # endif
 
@@ -1425,9 +1426,12 @@
     // Csh also needs to have "\n" escaped twice when do_special is set.
     csh_like = csh_like_shell();
 
+    // PowerShell uses it's own version for quoting single quotes
+    shname = gettail(p_sh);
+    powershell = strstr((char *)shname, "pwsh") != NULL;
 # ifdef MSWIN
-    // PowerShell only accepts single quotes so override p_ssl.
-    powershell = strstr((char *)gettail(p_sh), "powershell") != NULL;
+    powershell = powershell || strstr((char *)shname, "powershell") != NULL;
+    // PowerShell only accepts single quotes so override shellslash.
     double_quotes = !powershell && !p_ssl;
 # endif
 
@@ -1445,11 +1449,9 @@
 # endif
 	if (*p == '\'')
 	{
-# ifdef MSWIN
 	    if (powershell)
 		length +=2;		// ' => ''
 	    else
-# endif
 		length += 3;		// ' => '\''
 	}
 	if ((*p == '\n' && (csh_like || do_newline))
@@ -1497,14 +1499,12 @@
 # endif
 	    if (*p == '\'')
 	    {
-# ifdef MSWIN
 		if (powershell)
 		{
 		    *d++ = '\'';
 		    *d++ = '\'';
 		}
 		else
-# endif
 		{
 		    *d++ = '\'';
 		    *d++ = '\\';
diff --git a/src/option.c b/src/option.c
index 5fc059e..ae30310 100644
--- a/src/option.c
+++ b/src/option.c
@@ -933,8 +933,8 @@
 	    }
 	}
 # ifdef MSWIN
-	// PowerShell 5.1/.NET outputs UTF-16 with BOM so re-encode to the
-	// current codepage
+	// Windows PowerShell output is UTF-16 with BOM so re-encode to the
+	// current codepage.
 	else if (   fnamecmp(p, "powershell") == 0
 		    || fnamecmp(p, "powershell.exe") == 0
 		)
@@ -965,6 +965,7 @@
 		    || fnamecmp(p, "fish") == 0
 		    || fnamecmp(p, "ash") == 0
 		    || fnamecmp(p, "dash") == 0
+		    || fnamecmp(p, "pwsh") == 0
 # ifdef MSWIN
 		    || fnamecmp(p, "cmd") == 0
 		    || fnamecmp(p, "sh.exe") == 0
@@ -976,6 +977,7 @@
 		    || fnamecmp(p, "bash.exe") == 0
 		    || fnamecmp(p, "cmd.exe") == 0
 		    || fnamecmp(p, "dash.exe") == 0
+		    || fnamecmp(p, "pwsh.exe") == 0
 # endif
 		    )
 	    {
@@ -985,7 +987,10 @@
 #  ifdef MSWIN
 		    p_sp = (char_u *)">%s 2>&1";
 #  else
-		    p_sp = (char_u *)"2>&1| tee";
+		    if (fnamecmp(p, "pwsh") == 0)
+			p_sp = (char_u *)">%s 2>&1";
+		    else
+			p_sp = (char_u *)"2>&1| tee";
 #  endif
 		    options[idx_sp].def_val[VI_DEFAULT] = p_sp;
 		}
@@ -1011,6 +1016,7 @@
      *			    p_shcf	p_sxq
      * cmd.exe          -   "/c"	"("
      * powershell.exe   -   "-Command"	"\""
+     * pwsh.exe		-   "-c"	"\""
      * "sh" like shells -   "-c"	"\""
      *
      * For Win32 p_sxq is set instead of p_shq to include shell redirection.
diff --git a/src/os_win32.c b/src/os_win32.c
index 1a005c9..eff2269 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2135,6 +2135,7 @@
     char_u	*pathbuf = NULL;
     char_u	*pathext = NULL;
     char_u	*pathextbuf = NULL;
+    char_u	*shname = NULL;
     int		noext = FALSE;
     int		retval = FALSE;
 
@@ -2142,8 +2143,10 @@
 	return FALSE;
 
     // Using the name directly when a Unix-shell like 'shell'.
-    if (strstr((char *)gettail(p_sh), "powershell") == NULL
-				&& strstr((char *)gettail(p_sh), "sh") != NULL)
+    shname = gettail(p_sh);
+    if (strstr((char *)shname, "sh") != NULL &&
+	!(strstr((char *)shname, "powershell") != NULL
+				    || strstr((char *)shname, "pwsh") != NULL))
 	noext = TRUE;
 
     if (use_pathext)
diff --git a/src/testdir/test_shell.vim b/src/testdir/test_shell.vim
index 753a0d5..f5a3e98 100644
--- a/src/testdir/test_shell.vim
+++ b/src/testdir/test_shell.vim
@@ -19,7 +19,8 @@
           \ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
           \ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
           \ ['csh', '-c', '|& tee', '', '>&', '', ''],
-          \ ['tcsh', '-c', '|& tee', '', '>&', '', '']]
+          \ ['tcsh', '-c', '|& tee', '', '>&', '', ''],
+          \ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '', '']]
   endif
   if has('win32')
     let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''],
@@ -28,6 +29,8 @@
           \           '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'],
           \ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '',
           \               '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'],
+          \ ['pwsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
+          \ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
           \ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
           \ ['ksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
           \ ['mksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
@@ -61,6 +64,7 @@
       let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'"
       let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'"
     elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$'
+          \ || e[0] =~# '.*pwsh$' || e[0] =~# '.*pwsh.exe$'
       let str1 = "'cmd \"arg1\" ''arg2'' !%#'"
       let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'"
     else
@@ -76,9 +80,14 @@
       let [&shellcmdflag, &shellpipe, &shellquote, &shellredir,
             \ &shellxescape, &shellxquote] = e[1:6]
       new
-      r !echo hello
-      call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0])
-      bwipe!
+      try
+        r !echo hello
+        call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0])
+      catch
+        call assert_report('Failed to run shell command, shell: ' .. e[0])
+      finally
+        bwipe!
+      endtry
     endif
   endfor
   set shell& shellcmdflag& shellpipe& shellquote&
@@ -149,6 +158,8 @@
   " ".*\\\\[^\\\\]*$"
   let shells = [['cmd', '/c', '\\', '/'],
         \ ['powershell', '-Command', '\\', '/'],
+        \ ['pwsh', '-Command', '\\', '/'],
+        \ ['pwsh', '-c', '\\', '/'],
         \ ['sh', '-c', '/', '/']]
   for e in shells
     exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1]
diff --git a/src/version.c b/src/version.c
index 3c626bb..e9ad71b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3079,
+/**/
     3078,
 /**/
     3077,