help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: counsel-dired-jump error "find: paths must precede expression:"


From: Yuri Khan
Subject: Re: counsel-dired-jump error "find: paths must precede expression:"
Date: Thu, 18 Jan 2018 13:46:48 +0700

On Thu, Jan 18, 2018 at 9:39 AM, John Magolske <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]