Subject: 28.0.50; [PATCH] AngeFTP fails on macOS 10.14 with GNU inetutils FTP

From: Alex Bochannek <[email-masked]>
Date: Mon, 17 May 2021 20:53:41 -0700

AngeFTP cannot parse the output of the GNU inetutils FTP client on macOS
10.14. It errors out with "FTP Error: OPEN request failed:" and the
process buffer shows the following:

ftp> open ftp.tcl.tk
open ftp.tcl.tk
cd /
cd /
cd /
cd /
cd /
cd /
cd /
cd /
cd /
cd /
cd /
cd /
Connected to ftp.tcl.tk.
421 Service not available, remote server has closed connection
ftp> Not connected.
ftp> Not connected.
ftp> Not connected.
ftp> Not connected.
ftp> Not connected.
ftp> Not connected.
ftp> 

This appears to be caused by readline being enabled for ftp and is
resolved when disabling it.

NetBSD/FreeBSD specifically mentions this in its ftp(1) for tnftp:

     -e		 Disables command line editing.	 This is useful	for Emacs
		 ange-ftp mode.

Netkit-ftp on Linux does not exhibit this problem even with readline
enabled; I could not test GNU inetutils on Linux. I tested tnftp on
macOS and it also did not exhibit this problem even with readline
enabled.

Tested versions:
ftp (GNU inetutils) 2.0 macOS 10.14.6
tnftp-20200705 macOS 10.14.6
netkit-ftp 0.17-34.1 Ubuntu 20.04.2 LTS

There is no -e option for Windows FTP and ftp will terminate when
receiving an unknown option (tested version Windows 10.0.19042.928)

There is no -e option in Solaris FTP and I cannot test how it responds
to an unknown option.

I am proposing the below patch which resolves the problem on macOS with
GNU inetutils and does no harm for Netkit-ftp/lukemftp/tnftp.

However, because of the way a Windows client would respond, I am open to
different approaches including considering this an inetutils bug
instead.

diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 04ea809127..1742c68c38 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -948,7 +948,7 @@ ange-ftp-gateway-ftp-program-name
   :group 'ange-ftp
   :type 'string)
 
-(defcustom ange-ftp-ftp-program-args '("-i" "-n" "-g" "-v")
+(defcustom ange-ftp-ftp-program-args '("-i" "-n" "-g" "-v" "-e")
   "A list of arguments passed to the FTP program when started."
   :group 'ange-ftp
   :type '(repeat string))

In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G9028))
 of 2021-05-17 built on awb-mbp.local
Repository revision: d83db639d379df142482bf82d7eb020d2ec1ae73
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1671
System Description:  Mac OS X 10.14.6

-- 
Alex.