* counsel-dired-jump error "find: paths must precede expression:"
@ 2018-01-18 2:39 John Magolske
2018-01-18 6:46 ` Yuri Khan
0 siblings, 1 reply; 6+ messages in thread
From: John Magolske @ 2018-01-18 2:39 UTC (permalink / raw)
To: help-gnu-emacs
When issuing the command counsel-dired-jump from some directories I'll
get this error message:
find: paths must precede expression: A1
Try 'find --help' for more information.
yet from other directories the command works fine, allowing fuzzy
searching for a directory to open dired at. I can't sort out why
this error message comes up in some directories and not others...
TIA for any clues,
John
--
John Magolske
http://b79.net/contact
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: counsel-dired-jump error "find: paths must precede expression:"
2018-01-18 2:39 counsel-dired-jump error "find: paths must precede expression:" John Magolske
@ 2018-01-18 6:46 ` Yuri Khan
2018-01-19 8:13 ` John Magolske
0 siblings, 1 reply; 6+ messages in thread
From: Yuri Khan @ 2018-01-18 6:46 UTC (permalink / raw)
To: John Magolske; +Cc: help-gnu-emacs
On Thu, Jan 18, 2018 at 9:39 AM, John Magolske <listmail@b79.net> wrote:
> When issuing the command counsel-dired-jump from some directories I'll
> get this error message:
>
> find: paths must precede expression: A1
> Try 'find --help' for more information.
>
> yet from other directories the command works fine, allowing fuzzy
> searching for a directory to open dired at. I can't sort out why
> this error message comes up in some directories and not others...
The source of ‘counsel-dired-jump’:
https://github.com/abo-abo/swiper/blob/master/counsel.el#L2183
contains this expression:
(shell-command-to-string
(concat find-program " * -type d -not -path '*\/.git*'"))
The * in the first argument will be expanded by the shell to a list of
all files in the current directory, in unspecified order. If any of
them happens to look like a ‘find’ option, ‘find’ will try to
interpret it as one, with unintended consequences.
For example, on my system the following example breaks with the
message you quoted:
~$ mkdir /tmp/foo
~$ cd /tmp/foo
/tmp/foo$ touch -- ! A1
/tmp/foo$ echo *
! A1
/tmp/foo$ find * -type d -not -path '*/.git*'
find: paths must precede expression: A1
I was also able to cause data loss:
~$ mkdir /tmp/bar
~$ cd /tmp/bar
/tmp/bar$ touch -- aaa bbb ccc -delete
/tmp/bar$ ls
aaa bbb ccc -delete
/tmp/bar$ find * -type d -not -path '*/.git*'
/tmp/bar$ ls
-delete
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: counsel-dired-jump error "find: paths must precede expression:"
2018-01-18 6:46 ` Yuri Khan
@ 2018-01-19 8:13 ` John Magolske
2018-01-19 9:47 ` Robert Pluim
2018-01-19 10:07 ` Eli Zaretskii
0 siblings, 2 replies; 6+ messages in thread
From: John Magolske @ 2018-01-19 8:13 UTC (permalink / raw)
To: help-gnu-emacs
Thanks for the clarifying explanation,
* Yuri Khan <yuri.v.khan@gmail.com> [180117 23:14]:
> The source of ‘counsel-dired-jump’:
>
> https://github.com/abo-abo/swiper/blob/master/counsel.el#L2183
>
> contains this expression:
>
> (shell-command-to-string
> (concat find-program " * -type d -not -path '*\/.git*'"))
>
> The * in the first argument will be expanded by the shell to a list of
> all files in the current directory, in unspecified order. If any of
> them happens to look like a ‘find’ option, ‘find’ will try to
> interpret it as one, with unintended consequences.
looking into this further, I found a quoted wildcard resolves the issue:
(shell-command-to-string
(concat find-program " -path './*' -type d -not -path '*\/.git*'"))
Seems to behave pretty much the same, except that all the directory
file-paths displayed in the minibuffer are now preceded with a ./
> [...]
>
> I was also able to cause data loss:
>
> ~$ mkdir /tmp/bar
> ~$ cd /tmp/bar
> /tmp/bar$ touch -- aaa bbb ccc -delete
> /tmp/bar$ ls
> aaa bbb ccc -delete
> /tmp/bar$ find * -type d -not -path '*/.git*'
> /tmp/bar$ ls
> -delete
--
John Magolske
http://b79.net/contact
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: counsel-dired-jump error "find: paths must precede expression:"
2018-01-19 8:13 ` John Magolske
@ 2018-01-19 9:47 ` Robert Pluim
2018-01-19 10:11 ` tomas
2018-01-19 10:07 ` Eli Zaretskii
1 sibling, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2018-01-19 9:47 UTC (permalink / raw)
To: John Magolske; +Cc: help-gnu-emacs
John Magolske <listmail@b79.net> writes:
> looking into this further, I found a quoted wildcard resolves the issue:
>
> (shell-command-to-string
> (concat find-program " -path './*' -type d -not -path '*\/.git*'"))
>
> Seems to behave pretty much the same, except that all the directory
> file-paths displayed in the minibuffer are now preceded with a ./
What's wrong with using "find ." instead of "find './*'"?
Robert
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: counsel-dired-jump error "find: paths must precede expression:"
2018-01-19 9:47 ` Robert Pluim
@ 2018-01-19 10:11 ` tomas
0 siblings, 0 replies; 6+ messages in thread
From: tomas @ 2018-01-19 10:11 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, Jan 19, 2018 at 10:47:35AM +0100, Robert Pluim wrote:
> John Magolske <listmail@b79.net> writes:
>
> > looking into this further, I found a quoted wildcard resolves the issue:
> >
> > (shell-command-to-string
> > (concat find-program " -path './*' -type d -not -path '*\/.git*'"))
> >
> > Seems to behave pretty much the same, except that all the directory
> > file-paths displayed in the minibuffer are now preceded with a ./
>
> What's wrong with using "find ." instead of "find './*'"?
They are at least different: I don't know whether that is relevant here.
With "find .", the start set is the current directory; it would also
find files and subdirs of "." whose name starts with a dot.
With "find ./*", the shell would have a go at expanding ./* into
the list of entries of the current directory: find's start set would
be that list, as expanded by the shell. By default[1], that expansion
excludes entries whose name start with a dot (thus the -not -path ...
up there seems superfluous).
Cheers
[1] But cf "shopt dotglob" for bash, for example. Shells tend to
vary in this department. Note that the shell expansion of
./* can vary even more wildly, cf. bash's "set noglob".
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlphxDsACgkQBcgs9XrR2kaGJwCfY+3Jf3ScGiLDVnY0nyUtdaMd
MfMAn2zVmOgsALLgwoCQwzSwR0syWYwc
=2ZOs
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: counsel-dired-jump error "find: paths must precede expression:"
2018-01-19 8:13 ` John Magolske
2018-01-19 9:47 ` Robert Pluim
@ 2018-01-19 10:07 ` Eli Zaretskii
1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2018-01-19 10:07 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 19 Jan 2018 00:13:02 -0800
> From: John Magolske <listmail@b79.net>
>
> > https://github.com/abo-abo/swiper/blob/master/counsel.el#L2183
> >
> > contains this expression:
> >
> > (shell-command-to-string
> > (concat find-program " * -type d -not -path '*\/.git*'"))
> >
> > The * in the first argument will be expanded by the shell to a list of
> > all files in the current directory, in unspecified order. If any of
> > them happens to look like a ‘find’ option, ‘find’ will try to
> > interpret it as one, with unintended consequences.
>
> looking into this further, I found a quoted wildcard resolves the issue:
>
> (shell-command-to-string
> (concat find-program " -path './*' -type d -not -path '*\/.git*'"))
Beware: this uses quoting that will fail on non-Posix hosts. For
portable code, always use shell-quote-argument instead of literal
quotes and backslash-escapes.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-19 10:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-18 2:39 counsel-dired-jump error "find: paths must precede expression:" John Magolske
2018-01-18 6:46 ` Yuri Khan
2018-01-19 8:13 ` John Magolske
2018-01-19 9:47 ` Robert Pluim
2018-01-19 10:11 ` tomas
2018-01-19 10:07 ` Eli Zaretskii
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.