all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Jonathan Kyle Mitchell <kyle@jonathanmitchell.org>
Cc: 30724@debbugs.gnu.org, Yegor Timoshenko <yegortimoshenko@riseup.net>
Subject: bug#30724: eshell: escaped tilde is not treated as such
Date: Mon, 16 Jul 2018 20:14:03 -0400	[thread overview]
Message-ID: <87sh4i90s4.fsf@gmail.com> (raw)
In-Reply-To: <88c6e336a6a9a5362a1e878b2df9d7ffffc61f7a.camel@jonathanmitchell.org> (Jonathan Kyle Mitchell's message of "Sun, 15 Jul 2018 12:18:26 -0500")

Jonathan Kyle Mitchell <kyle@jonathanmitchell.org> writes:

> After tracing through the execution of eshell some more, I noticed that
> eshell sets an escaped text property on the arguments when the user
> escaped them with `\' or quote characters but there is nothing in
> eshell that does anything with it apparently.

Yeah, this sort of half-finished thing seems to pop up in eshell quite a
bit.

> Subject: [PATCH] Check for special filenames in eshell (Bug#30724)
>
> 	* lisp/eshell/em-dirs.el (eshell/cd): Add
> 	eshell-escape-special-filenames to symbol plist.
> 	(eshell/pushd): Likewise.
> 	(eshell/popd): Likewise.
>
> 	* lisp/eshell/em-ls.el (eshell/ls): Add
> 	eshell-escape-special-filenames to symbol plist.
>
> 	* lisp/eshell/em-unix.el (eshell/rm): Add
> 	eshell-escape-special-filenames to symbol plist.
> 	(eshell/mkdir): Likewise.
> 	(eshell/rmdir): Likewise.
> 	(eshell/mv): Likewise.
> 	(eshell/cp): Likewise.
> 	(eshell/ln): Likewise.
> 	(eshell/cat): Likewise.
> 	(eshell/du): Likewise.
> 	(eshell/diff): Likewise.
>
> 	* lisp/eshell/esh-cmd.el (eshell-lisp-command):	Check for
> 	single character escaped string arguments (Bug#30724).
>
> 	* lisp/eshell/esh-ext.el (eshell/addpath): Add
> 	eshell-escape-special-filenames to symbol plist.

The "Add eshell-escape-special-filenames to symbol plist" should be
coalesced, as in:

* lisp/eshell/em-dirs.el (eshell/cd, eshell/pushd, eshell/popd):
* lisp/eshell/em-ls.el (eshell/ls):
* lisp/eshell/em-unix.el (eshell/rm, eshell/mkdir, eshell/rmdir)
(eshell/mv, eshell/cp, eshell/ln, eshell/cat, eshell/du, eshell/diff):
* lisp/eshell/esh-ext.el (eshell/addpath): Add
eshell-escape-special-filenames to symbol plist.

* lisp/eshell/esh-cmd.el (eshell-lisp-command):	Check for
single character escaped string arguments (Bug#30724).
  

> +		  (let ((numeric (not (get object
> +                                           'eshell-no-numeric-conversions)))
> +			(escaped (get object 'eshell-escape-special-filenames)))

I'm not sure 'escaped' or 'eshell-escape-special-filenames' are really
the right names here, as they're not actually indicating any escaping.
Maybe the property should be something like 'eshell-filename-arguments'?

> +		    (when (or numeric escaped)
> +		      (while args
> +			(let ((arg (car args)))
> +			  (cond ((and numeric (stringp arg) (> (length arg) 0)
> +				      (text-property-any 0 (length arg)
> +							 'number t arg))
> +				 ;; if any of the arguments are flagged as
> +				 ;; numbers waiting for conversion, convert
> +				 ;; them now

Comments should be capitalized and end with a period (I know the
original didn't, but since we're updating the code, now is a good time
to fix it).

> +				 (setcar args (string-to-number arg)))
> +				((and escaped (stringp arg) (= (length arg) 1)
> +				      (text-property-any 0 (length arg)
> +							 'escaped t arg))
> +				 ;; if any of the arguments are single
> +				 ;; character escaped filenames,
> +				 ;; prepend "./"
> +				 (setcar args (concat "./" arg)))))

It looks like this kind of escaping isn't actually needed for "*" which
your previous patch mentioned.  Perhaps just check for "~" explicitly,
rather than any single character filenames.  Or are there other examples
besides "~" which need "./" to prevent interpretation?






  reply	other threads:[~2018-07-17  0:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06  4:30 bug#30724: eshell: escaped tilde is not treated as such Yegor Timoshenko
2018-03-09  1:15 ` Noam Postavsky
2018-07-06  7:24 ` Jonathan Kyle Mitchell
2018-07-07 19:17   ` Noam Postavsky
2018-07-15 17:18     ` Jonathan Kyle Mitchell
2018-07-17  0:14       ` Noam Postavsky [this message]
2018-07-18  3:54         ` Jonathan Kyle Mitchell
2018-07-22  1:34           ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sh4i90s4.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=30724@debbugs.gnu.org \
    --cc=kyle@jonathanmitchell.org \
    --cc=yegortimoshenko@riseup.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.