geophile / marcel

A modern shell
https://marceltheshell.org
GNU General Public License v3.0
335 stars 13 forks source link

Bug: spaceful path handling #20

Open rhn opened 10 months ago

rhn commented 10 months ago
$ ls /mnt/space/games/Cryostasis\ 2.0.0.13\ [GOG]/
No qualifying paths, (possibly due to permission errors): ['/mnt/space/games/Cryostasis 2.0.0.13 [GOG]/']

Meanwhile, bash can list it just fine.

Getting the path through tab-completion does not escape the spaces, either.

geophile commented 10 months ago

I know about the tab completion issue, I'm tracking that as a bug.

The other problem is new and more subtle. It looks like the problem is related to the brackets, not the spaces. Here's what I'm seeing:

M 0.18.3 jao@loon /tmp/t$ touch a\ b
M 0.18.3 jao@loon /tmp/t$ touch \ c\ d
M 0.18.3 jao@loon /tmp/t$ touch \[xyz\]
M 0.18.3 jao@loon /tmp/t$ ls a*
-rw-rw-r--   jao    jao           0   2023 Oct 24 17:06:46   a b
M 0.18.3 jao@loon /tmp/t$ ls a\ b
-rw-rw-r--   jao    jao           0   2023 Oct 24 17:06:46   a b
M 0.18.3 jao@loon /tmp/t$ ls \ c*
-rw-rw-r--   jao    jao           0   2023 Oct 24 17:06:52    c d
M 0.18.3 jao@loon /tmp/t$ ls \ c\ d
-rw-rw-r--   jao    jao           0   2023 Oct 24 17:06:52    c d
M 0.18.3 jao@loon /tmp/t$ ls \[*
-rw-rw-r--   jao    jao           0   2023 Oct 24 17:07:00   [xyz]
M 0.18.3 jao@loon /tmp/t$ ls *\]
-rw-rw-r--   jao    jao           0   2023 Oct 24 17:07:00   [xyz]
M 0.18.3 jao@loon /tmp/t$ ls \[xyz\]
No qualifying paths, (possibly due to permission errors): ['[xyz]']

I'll now tracking this as a bug.

geophile commented 10 months ago

I see. Marcel is interpreting ...[GOG], and [xyz] as glob expressions.

I'm not saying that bash is wrong, but it is surprising to me. Look at this:

jao@loon:/tmp/t$ touch [xyz] x y z
jao@loon:/tmp/t$ ls
 x  '[xyz]'   y   z
jao@loon:/tmp/t$ ls [xyz]
x  y  z
jao@loon:/tmp/t$ rm x y
jao@loon:/tmp/t$ ls [xyz]
z
jao@loon:/tmp/t$ rm z
jao@loon:/tmp/t$ ls [xyz]
'[xyz]'

bash interprets [xyz] as a glob expression if that interpretation yields any files. Otherwise (after x, y, and z are gone), it interprets [xyz] literally.