-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CD Improvement #122
Comments
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
1. Check if the command is a builtin internal, and if so, execute it.
2. Check if the command refers to an executable file, including extension, and if so, execute that.
3. 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.
4. 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:
1. Check if the command is an executable file, including adding path and pathext, and if something is found execute it. (This was preexisting behavior.)
2. Check if the command is a builtin, and if so, execute that. (This was preexisting behavior.)
3. 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
The text was updated successfully, but these errors were encountered: