From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70792: 30.0.50; [PATCH] Add Eshell support for expanding absolute file names within the current remote connection Date: Mon, 06 May 2024 21:43:00 +0300 Message-ID: <86cypybx3f.fsf@gnu.org> References: <5b881f54-4c29-f8d8-d1f7-57b44e7cfc80@gmail.com> <86y18nb3ap.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22635"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70792@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 06 20:44:12 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s43Ji-0005Iz-Iz for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 May 2024 20:44:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s43JO-0006k3-Kz; Mon, 06 May 2024 14:43:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s43JK-0006iB-0x for bug-gnu-emacs@gnu.org; Mon, 06 May 2024 14:43:38 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s43JJ-0003jG-Ct for bug-gnu-emacs@gnu.org; Mon, 06 May 2024 14:43:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s43Jh-0005hH-Mz for bug-gnu-emacs@gnu.org; Mon, 06 May 2024 14:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 May 2024 18:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70792 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70792-submit@debbugs.gnu.org id=B70792.171502102921882 (code B ref 70792); Mon, 06 May 2024 18:44:01 +0000 Original-Received: (at 70792) by debbugs.gnu.org; 6 May 2024 18:43:49 +0000 Original-Received: from localhost ([127.0.0.1]:39594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s43JU-0005gs-Un for submit@debbugs.gnu.org; Mon, 06 May 2024 14:43:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s43JG-0005gY-Q0 for 70792@debbugs.gnu.org; Mon, 06 May 2024 14:43:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s43In-0003eV-3n; Mon, 06 May 2024 14:43:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+ZUcysqxL6FD9h1hGQ6vQz1wMSqaTfA9RaJtVdPziug=; b=ne2P7RLE3a/Q WnBImOes9StDNqir5qTkc9EkmrW1AzHk096xjCAeA9cWQx0mFi0KFG6f8mHHAUKnGXI6ifhVRD7KU Unqe+ql/XYpKhNymYsfLgC4QTO3kn2xEnNcIAPFaEbsKiMXcHkSKrXGcRf0oll0lhyYLHTz70lC4l 0yYKkhI0GWXQR56FQoMe4k2YjR9bPpjgPXHDcDZLBqkclAG0Gy0pFlybgbJHOIj1q731dsZBejRB0 XNF/3jHsAFwvF+2Fa5ZaCQ6Lag2zYJw8/JpnZBG2knYgk+yPxQv1P0+iqi261M9DBv9MG2QcJlFpD jStBBC/4cFYE3S+Z1y1SNw==; In-Reply-To: (message from Jim Porter on Mon, 6 May 2024 11:13:20 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284604 Archived-At: > Date: Mon, 6 May 2024 11:13:20 -0700 > Cc: 70792@debbugs.gnu.org > From: Jim Porter > > File names are expanded according to the current working directory when > you enter your command, so unless you explicitly type out the host in a > file name, it's treated as belonging to the host associated with cwd. I know this, but we are explicitly talking about _absolute_ file names, which normally trivially expand to themselves. _That_ is the problem which I was talking about: you seem to propose a feature where an absolute file name is sometimes expanded not to itself, but to a remote file name. > ##### 1. Change to root > ~ $ cd /sudo:: > /sudo:root@host:~ # pwd; *pwd > /sudo:root@host:/root > /root > > ##### 2. Change to an absolute directory, stay as root > /sudo:root@host:~ # cd /etc; pwd; *pwd > /sudo:root@host:/etc > /etc So you are saying that to chdir to the _local_ /etc I must quote it as in "/:/etc", or somesuch? If not, how do I chdir to a local directory by its absolute file name? > ##### 3. Change to the home directory, stay as root > /sudo:root@host:~ # cd ~; pwd; *pwd > /sudo:root@host:/root > /root Likewise here: how to chdir to the _local_ home directory? quote it? > ##### 4. Write the expanded "~/foo.txt" to the *local* "~/bar.txt". > ##### Using "/:" quoting lets you explicitly name a local file > /sudo:root@host:~ # *echo ~/foo.txt > /:~/bar.txt > /sudo:root@host:~ # cat bar.txt > /bin/cat: bar.txt: No such file or directory > > ##### 5. Change to the *local* home directory, stop being root > /sudo:root@host:~ # cd /:~; pwd; *pwd > /home/jim > /home/jim That's awful! Completely un-natural, let alone a lot of typing! Also, am I still able to specify remote file names when my default directory is local? Or do I have to chdir to a remote directory first? > ##### 6. "bar.txt" ended up here > ~ $ cat bar.txt > ['-c', '/root/foo.txt'] Is "/root/foo.txt" a local or remote file name? (I know you used *echo, but the file bar.text has no memory of that.) > In the last line above, note that the value we wrote to our file is just > the local part. And that's considered a feature?? > With this option *disabled* (the default), there are some problems that > (in my opinion) make working with remote file names in Eshell even more > complex. For example, suppose I'm on a remote host, and want to change > to my home directory on that remote. There's not an easy way to do that: The simplest solution is to introduce a special command for that, so that the user could tell Eshell explicitly whether he/she wants to consider him/herself on the local or the remote host. Similar to what we did with rlogin or ssh. > Or suppose my cwd is /ssh:user@remote:/somedir. If I run "cat > /etc/hosts", Eshell will print my local hosts file. But what if I run > "cat -n /etc/hosts"? Eshell's "cat" implementation doesn't understand > "-n", so it calls the "cat" on "remote". Now it prints the remote hosts > file. You can only predict which hosts files you'll get if you know > exactly which flags Eshell's "cat" implementation supports. If Eshel knew that I consider myself on the remote, it could have modified the logic accordingly, to DTRT. Without such an explicit knowledge, we are _guessing_, and our guesses are bound to be wrong sometimes. Bottom line: instead of trying to improve our guesswork, I suggest to explore the possibility of adding new command(s) that will tell Eshell exactly what the user means wrt local/remote operation.