Closed PIRANY1 closed 8 months ago
It’s currently not fully possible. You could use alias cd..=cd ..
but that only works for one specific path.
When writing Yori I was trying to avoid “special” parsing rules that apply per command. The goal was to allow other developers to write commands – internal or external – so special rules went against the goal.
Looking at CMD now though, it is following rules, just subtle and difficult to understand ones. I don’t understand them fully. But roughly, it looks like
Check if the command is a builtin internal, and if so, execute it.
Check if the command refers to an executable file, including extension, and if so, execute that.
Re-parse the command and treat “.”, “/” and “\” as seperators. Text at the separator is moved to become the first argument. Check if the text before the separator is a builtin.
If it’s not a builtin, go back and look for path/pathext matches.
It still seems inconsistent though. “Echo..” will echo “.”; “echo\” will not echo anything (ie., the first char seems ignored.) But cd can’t skip the first character.
Note there’s a lot of ambiguity in these rules. “cd\foo.exe” might mean “execute foo.exe” or might mean “change directory to foo.exe” depending on whether cd\foo.exe exists. It also seems to execute real executables regardless of file extension, so “cd.foo” can change directory to .foo or execute “cd.foo” as a real executable.
Anyway, Yori’s evaluation is different. It also can’t solve the ambiguity, so my advice is to use these shortcuts as accelerators where you trust the directory contents.
So, I just pushed a change which does something similar:
Check if the command is an executable file, including adding path and pathext, and if something is found execute it. (This was preexisting behavior.)
Check if the command is a builtin, and if so, execute that. (This was preexisting behavior.)
Re-parse the command and treat “.”, “/” and “\” as seperators. Text at the separator is moved to become the first argument. Resolve any alias in the command. After alias resolution, check if it’s a builtin command, and if so, execute it.
Note that in CMD, aliases are really evaluated by conhost and have no awareness about these rules. In Yori, many built-ins are really aliases (eg. “cd” is an alias for “chdir” so if aliases weren’t expanded, this wouldn’t work.)
Okay Thank you
In a Normal Terminal Session you can use "cd.." without the space between "cd" and ".." to go a Directory back. Is this Possible too in yori?