jhspetersson / fselect

Find files with SQL-like queries
https://fselect.rocks
Apache License 2.0
4.02k stars 85 forks source link

Not working when PATH have spaces! #150

Open Dominiquini opened 5 months ago

Dominiquini commented 5 months ago

I tested both in Windows as Linux (WSL2) and in both cases, the application freezes when I try to query some folder with spaces in it!

fselect.exe name from ".\Library\Downloads\ZZZ - Others\" (The application freezes and I need to kill (CTRL-C)

fselect.exe name from ".\Library\Downloads\ZZZ\" (The application works fine!

I tried multiple ways to escape the full paths or only the spaces, but nothing appears to work!

Thanks

jhspetersson commented 5 months ago

Thank so much for the issue!

Escaping on the Windows is a mess. Depending on what terminal you are using, cmd.exe or PowerShell, and what version of PowerShell exactly, it is a bit different.

First of all, please check if this (triple single quotes) works for you:

fselect.exe name from '''C:\Projects\test test\'''

In case of cmd.exe single quotes should work:

fselect.exe name from 'C:\Projects\test test\'

Nevertheless, there is a few bugs in lexer's code I got to fix, and, more importantly, document the usage of all those quotes.

Dominiquini commented 5 months ago

Thank so much for the issue!

Escaping on the Windows is a mess. Depending on what terminal you are using, cmd.exe or PowerShell, and what version of PowerShell exactly, it is a bit different.

First of all, please check if this (triple single quotes) works for you:

fselect.exe name from '''C:\Projects\test test\'''

It worked!

In case of cmd.exe single quotes should work:

fselect.exe name from 'C:\Projects\test test\'

It worked!

Nevertheless, there is a few bugs in lexer's code I got to fix, and, more importantly, document the usage of all those quotes.

But there is still the case that I could not make work in directories with space in WSL using bash!

Thanks

Dominiquini commented 5 months ago

You can make a new release with the fix (https://github.com/jhspetersson/fselect/commit/7e77c40b1dc414493c4317f657c447f479d46890)?

Thanks!

jhspetersson commented 5 months ago

Ok, so what about escaping on Linux or WSL?

The main point is to be able to pass the quotes to the command-line arguments somehow escaping them from the shell. This should work (quoting part of the string containing single quotes with double quotes):

fselect name from "'/home/user/test test/'"

Quoting the whole argument list with double quotes:

fselect "name from '/home/user/test test/'"

Or we can simply escape the single quotes:

fselect name from \'/home/user/test test/\'
Dominiquini commented 5 months ago

Ok, so what about escaping on Linux or WSL?

The main point is to be able to pass the quotes to the command-line arguments somehow escaping them from the shell. This should work (quoting part of the string containing single quotes with double quotes):

fselect name from "'/home/user/test test/'"

Quoting the whole argument list with double quotes:

fselect "name from '/home/user/test test/'"

Or we can simply escape the single quotes:

fselect name from \'/home/user/test test/\'

The samples that you provide worked. The problem with the escaping is that I loose the autocomplete feature from the terminal (on Windows and Linux). As I saw a commit of yours that seemed to be related, I thought it was worth publishing it! Anyway, thank you!

Great project this yours!