unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23959: 25.0.94; find: missing argument to `-exec'
@ 2016-07-12 19:27 Ethan Glasser-Camp
  2016-07-13  4:45 ` Tino Calancha
  2016-07-13  4:53 ` bug#23959: (no subject) Tino Calancha
  0 siblings, 2 replies; 8+ messages in thread
From: Ethan Glasser-Camp @ 2016-07-12 19:27 UTC (permalink / raw)
  To: 23959


1. Install fish-shell (http://fishshell.com/) and use it as your default
shell, although it may be enough to launch emacs from inside fish.

2. emacs -Q

3. M-x rgrep RET

4. any string RET

5. any directory RET

Expected result:

grep is invoked on the given directory and files are returned.

Actual result:

find: missing argument to `-exec'

I believe this is because the fish shell interprets the "{}" as a brace
expansion -- see
http://fishshell.com/docs/current/index.html#expand-brace -- and needs
the braces to be escaped. Editing the grep command using C-u and
inserting quotes around the braces makes it work as expected.



In GNU Emacs 25.0.94.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.20.4)
 of 2016-05-18 built on buildhw-10.phx2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.11803000
System Description:	Fedora release 24 (Twenty Four)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no --with-xwidgets build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
 -m64 -mtune=generic' LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XWIDGETS

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Loading /usr/share/emacs/site-lisp/site-start.d/desktop-entry-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/git-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/mercurial-site-start.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
You can run the command ‘set-variable’ with M-x s-va RET
Loading sendmail...done
user-error: Value ‘(quote header)’ does not match type choice of mail-envelope-from
M-p is undefined
You can run the command ‘set-variable’ with M-x s-va RET
Grep exited abnormally with code 1

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message idna format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader find-dired
dired grep compile comint ansi-color ring sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils cus-edit cus-start cus-load
wid-edit thingatpt help-fns help-mode easymenu cl-loaddefs pcase cl-lib
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting xwidget-internal move-toolbar
gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 114420 7060)
 (symbols 48 21837 0)
 (miscs 40 94 116)
 (strings 32 19996 4525)
 (string-bytes 1 562787)
 (vectors 16 13396)
 (vector-slots 8 444288 4260)
 (floats 8 179 7)
 (intervals 56 325 0)
 (buffers 976 13)
 (heap 1024 22685 1616))





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#23959: 25.0.94; find: missing argument to `-exec'
  2016-07-12 19:27 bug#23959: 25.0.94; find: missing argument to `-exec' Ethan Glasser-Camp
@ 2016-07-13  4:45 ` Tino Calancha
  2016-07-13 14:45   ` Eli Zaretskii
  2016-07-13  4:53 ` bug#23959: (no subject) Tino Calancha
  1 sibling, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2016-07-13  4:45 UTC (permalink / raw)
  To: 23959


Thank you for the report.
>I believe this is because the fish shell interprets the "{}" as a brace
>expansion -- see
>http://fishshell.com/docs/current/index.html#expand-brace -- and needs
>the braces to be escaped. Editing the grep command using C-u and
>inserting quotes around the braces makes it work as expected.
Yes, braces should be escaped in commands to be processed by a shell.
I am going to apply following patch to the master branch:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 2b44b58..f7f097b 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -543,7 +543,9 @@ grep-compute-defaults
    (let* ((host-id
  	  (intern (or (file-remote-p default-directory) "localhost")))
  	 (host-defaults (assq host-id grep-host-defaults-alist))
-	 (defaults (assq nil grep-host-defaults-alist)))
+	 (defaults (assq nil grep-host-defaults-alist))
+         (quot-braces (shell-quote-argument "{}"))
+         (quot-scolon (shell-quote-argument ";")))
      ;; There are different defaults on different hosts.  They must be
      ;; computed for every host once.
      (dolist (setting '(grep-command grep-template
@@ -637,9 +639,8 @@ grep-compute-defaults
  				     "")))
  			 (cons
  			  (if (eq grep-find-use-xargs 'exec-plus)
-			      (format "%s %s{} +" cmd0 null)
-			    (format "%s {} %s%s" cmd0 null
-				    (shell-quote-argument ";")))
+			      (format "%s %s%s +" cmd0 null quot-braces)
+			    (format "%s %s %s%s" cmd0 quot-braces null 
quot-scolon))
  			  (1+ (length cmd0)))))
  		      (t
  		       (format "%s . -type f -print | \"%s\" %s"
@@ -655,12 +656,11 @@ grep-compute-defaults
  			 (format "%s <D> <X> -type f <F> -print0 | \"%s\" 
-0 %s"
  				 find-program xargs-program gcmd))
  			((eq grep-find-use-xargs 'exec)
-			 (format "%s <D> <X> -type f <F> -exec %s {} %s%s"
-				 find-program gcmd null
-				 (shell-quote-argument ";")))
+			 (format "%s <D> <X> -type f <F> -exec %s %s %s%s"
+				 find-program gcmd quot-braces null 
quot-scolon))
  			((eq grep-find-use-xargs 'exec-plus)
-			 (format "%s <D> <X> -type f <F> -exec %s %s{} +"
-				 find-program gcmd null))
+			 (format "%s <D> <X> -type f <F> -exec %s %s%s +"
+				 find-program gcmd null quot-braces))
  			(t
  			 (format "%s <D> <X> -type f <F> -print | \"%s\" 
%s"
  				 find-program xargs-program gcmd))))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6)
  of 2016-07-13
Repository revision: 54b7eb0dee2397f1430e81b7356f8efb19946ba0






^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#23959: (no subject)
  2016-07-12 19:27 bug#23959: 25.0.94; find: missing argument to `-exec' Ethan Glasser-Camp
  2016-07-13  4:45 ` Tino Calancha
@ 2016-07-13  4:53 ` Tino Calancha
  2016-07-13 14:46   ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2016-07-13  4:53 UTC (permalink / raw)
  To: 23959-done

Fixed in master branch





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#23959: 25.0.94; find: missing argument to `-exec'
  2016-07-13  4:45 ` Tino Calancha
@ 2016-07-13 14:45   ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2016-07-13 14:45 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 23959

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 13 Jul 2016 13:45:15 +0900 (JST)
> 
> Thank you for the report.
> >I believe this is because the fish shell interprets the "{}" as a brace
> >expansion -- see
> >http://fishshell.com/docs/current/index.html#expand-brace -- and needs
> >the braces to be escaped. Editing the grep command using C-u and
> >inserting quotes around the braces makes it work as expected.
> Yes, braces should be escaped in commands to be processed by a shell.
> I am going to apply following patch to the master branch:
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
> index 2b44b58..f7f097b 100644
> --- a/lisp/progmodes/grep.el
> +++ b/lisp/progmodes/grep.el
> @@ -543,7 +543,9 @@ grep-compute-defaults
>     (let* ((host-id
>   	  (intern (or (file-remote-p default-directory) "localhost")))
>   	 (host-defaults (assq host-id grep-host-defaults-alist))
> -	 (defaults (assq nil grep-host-defaults-alist)))
> +	 (defaults (assq nil grep-host-defaults-alist))
> +         (quot-braces (shell-quote-argument "{}"))
> +         (quot-scolon (shell-quote-argument ";")))

But shell-quote-argument is not documented to support fish shell, is
it?  I think the problem is that the OP somehow sets up that shell as
the one used by Emacs when invoking shell commands, which is not a
recommended practice.

> -			      (format "%s %s{} +" cmd0 null)
> -			    (format "%s {} %s%s" cmd0 null
> -				    (shell-quote-argument ";")))
> +			      (format "%s %s%s +" cmd0 null quot-braces)
> +			    (format "%s %s %s%s" cmd0 quot-braces null 

I'm not sure we can assume a quoted argument can be safely
concatenated to an unquoted one.  (Yes, I know the original code used
that for the semi-colon.)

I can't say I'm happy with this solution, sorry.  But thanks for
working on this problem.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#23959: (no subject)
  2016-07-13  4:53 ` bug#23959: (no subject) Tino Calancha
@ 2016-07-13 14:46   ` Eli Zaretskii
  2016-07-13 14:52     ` Tino Calancha
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2016-07-13 14:46 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 23959, ethan.glasser.camp

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 13 Jul 2016 13:53:44 +0900 (JST)
> 
> Fixed in master branch

That was premature, please leave some time for people to respond to
the proposed solution.  Especially when the issue involves
portability.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#23959: (no subject)
  2016-07-13 14:46   ` Eli Zaretskii
@ 2016-07-13 14:52     ` Tino Calancha
  2016-07-13 15:15       ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2016-07-13 14:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 23959, Tino Calancha, ethan.glasser.camp



On Wed, 13 Jul 2016, Eli Zaretskii wrote:

> That was premature, please leave some time for people to respond to
> the proposed solution.  Especially when the issue involves
> portability.

Sure.  Sorry for my impetus Eli.
Please, don't hesitate to let me now if you want i revert this commit.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#23959: (no subject)
  2016-07-13 14:52     ` Tino Calancha
@ 2016-07-13 15:15       ` Eli Zaretskii
  2016-07-13 15:55         ` Clément Pit--Claudel
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2016-07-13 15:15 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 23959, tino.calancha, ethan.glasser.camp

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 13 Jul 2016 23:52:47 +0900 (JST)
> cc: Tino Calancha <tino.calancha@gmail.com>, 23959@debbugs.gnu.org, 
>     ethan.glasser.camp@gmail.com
> 
> On Wed, 13 Jul 2016, Eli Zaretskii wrote:
> 
> > That was premature, please leave some time for people to respond to
> > the proposed solution.  Especially when the issue involves
> > portability.
> 
> Sure.  Sorry for my impetus Eli.
> Please, don't hesitate to let me now if you want i revert this commit.

Let's hear what others think about this.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#23959: (no subject)
  2016-07-13 15:15       ` Eli Zaretskii
@ 2016-07-13 15:55         ` Clément Pit--Claudel
  0 siblings, 0 replies; 8+ messages in thread
From: Clément Pit--Claudel @ 2016-07-13 15:55 UTC (permalink / raw)
  To: 23959


[-- Attachment #1.1: Type: text/plain, Size: 706 bytes --]

On 2016-07-13 17:15, Eli Zaretskii wrote:
>> From: Tino Calancha <tino.calancha@gmail.com>
>> Date: Wed, 13 Jul 2016 23:52:47 +0900 (JST)
>> cc: Tino Calancha <tino.calancha@gmail.com>, 23959@debbugs.gnu.org, 
>>     ethan.glasser.camp@gmail.com
>>
>> On Wed, 13 Jul 2016, Eli Zaretskii wrote:
>>
>>> That was premature, please leave some time for people to respond to
>>> the proposed solution.  Especially when the issue involves
>>> portability.
>>
>> Sure.  Sorry for my impetus Eli.
>> Please, don't hesitate to let me now if you want i revert this commit.
> 
> Let's hear what others think about this.

Is there any reason why mapconcat + shell-quote-arguments doesn't work here?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-07-13 15:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 19:27 bug#23959: 25.0.94; find: missing argument to `-exec' Ethan Glasser-Camp
2016-07-13  4:45 ` Tino Calancha
2016-07-13 14:45   ` Eli Zaretskii
2016-07-13  4:53 ` bug#23959: (no subject) Tino Calancha
2016-07-13 14:46   ` Eli Zaretskii
2016-07-13 14:52     ` Tino Calancha
2016-07-13 15:15       ` Eli Zaretskii
2016-07-13 15:55         ` Clément Pit--Claudel

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).