#1213 find.command pb when directory or file contain spaces

SciTE (627)

Hi Neil,
If find.command is defined (e.g. find.command=grep -R -i --exclude=*.svn* --line-number "$(find.what)" $(find.directory)$(find.files)), then there is problem for directory or file with characters need to be escaped. I think also that final directory separator have to be given by FilePath::Directory() (allow to manage directories with space on the tail)

for example :
mkdir -p /tmp/directory\ with\ spaces\ /

I propose this patch.


  • Neil Hodgson

    Neil Hodgson - 2011-08-21

    You should place quotes around the path string.

  • Neil Hodgson

    Neil Hodgson - 2011-08-21
    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 3
  • Jérôme LAFORGE

    Ok but with quotes around the path, the shell doesn't interpret the wildcard (?,*).
    grep -Rn "something to find" '/tmp/aa ^$\,;:!<>^&"{([|`@)]}=/*'
    Furthermore, the directories can contain quote or double quotes into theirs names on modern unix's filesystem.
    You can't, easily, manage this case without escape.

    If you take the example into SciTEDOC.html :
    find "$(find.directory)" -name "$(find.files)"
    That doesn't work if find.directory or find.files contain double quotes.

  • Jérôme LAFORGE

    Maybe, I can propose a patch that can disable/enable ShellEscape with property and use quote for path.
    For letting choice to user whether he prefers escape the path/file or not.

  • Neil Hodgson

    Neil Hodgson - 2011-08-22

    Automatic quoting mechanisms often get in the way and this may not be completely compatible with existing use, especially when other quoting approaches have been used in the .properties file.

    Using the --include option of grep is likely to help with implementing what you want.

    The ShellEscape and Trim functions appear to return deallocated memory which may cause crashes with other compilers or runtime libraries.

  • Jérôme LAFORGE

    Ok, with --include option and quote are pretty good solution for me.
    There is still just a problem with directories that contain simple quote or double quotes.
    Thx again for your help.

  • Neil Hodgson

    Neil Hodgson - 2011-08-31

    The ShellEscape function starts at one position too far. It should be

    for \(int i = str.length\(\)-1; i &gt;= 0; --i\) \{
  • Jérôme LAFORGE

    Thx for reporting this bug.
    But this patch seems to be useless with --include option.


Log in to post a comment.