Closed ajalexei closed 1 year ago
Thanks for the report. I think the behavior here is wrong in both versions, and I have a change, but it still seems wrong.
Yori frequently parses things into ArgC/ArgV arrays, only to end up recombining them into strings. On Unix child processes receive ArgC/ArgV natively, so this works for most common cases. However, since ArgV is parsed by the shell and returned as a string, this parsing is lossy. In both cases "foo bar"
is parsed to foo bar
(without quotes.) What changed between 1.80 and 1.90 is x"y"
is parsed as x"y"
on 1.80 and xy
on 1.90.
In practical terms, this means that the first argument in alias, which typically specifies an alias, equals, and a command, previously retained quotes around the command and no longer does. However, in both versions, quotes around later arguments were discarded.
The change I want to make detects strings that require quotes (because they contain spaces) and reinserts them. This is done in quite a few places, but introduces its own share of quirks:
C:\>alias a1=dir "C:\Program Files\\$*$"
C:\>alias a2=dir "C:\Windows\\$*$"
C:\>alias
a1=ydir "C:\Program Files\\$*$"
a2=ydir C:\Windows\\$*$
C:\>a1 windows nt
Directory of C:\Program Files\windows nt
...
C:\>a1 "windows nt"
dir: no matching files found
C:\>a2 offline web pages
dir: no matching files found
C:\>a2 "offline web pages"
Directory of C:\Windows\offline web pages
...
Nonetheless it should fix the specific case you're concerned about:
C:\>alias
wp="C:\Program Files\Windows NT\Accessories\wordpad.exe" $*$
Another thing I noticed while looking into this is set
has similar parsing to alias
. The changes here probably also should be extended to set
, which is a bit terrifying given how commonly it's used.
The fix for this is released as part of Yori 2.0. Please let me know if you encounter further issues.
First, thanks a lot for the nice piece of work!
There seems to be a problem upon updating from 1.80 to 1.90: the aliases with spaces in the paths seem to have stopped working. Namely (example): _alias -s some_thing="C:\Program Files\some_thing\bin\something.exe" $*$ used to work with Yori 1.80, but now emits an error: "Unrecognized command: C:\Program" Is there a way to fix this behaviour?