Permalink
Browse files
'cd' without arguments should change to the home directory.
Addresses issue #24.
- Loading branch information...
Showing
with
16 additions
and 3 deletions.
- +8 −2 core/builtin.py
- +1 −1 core/cmd_exec.py
- +5 −0 spec/builtins.test.sh
- +2 −0 test/sh_spec.py
| @@ -401,9 +401,15 @@ def Shift(argv, mem): | ||
| return mem.Shift(n) | ||
| def _Cd(argv, mem): | ||
| def Cd(argv, mem): | ||
| # TODO: Parse flags, error checking, etc. | ||
| dest_dir = argv[0] | ||
| try: | ||
| dest_dir = argv[0] | ||
| except IndexError: | ||
| # NOTE: This is equivalent to 'cd ~', but bash/mksh only seem to respect | ||
| # $HOME, and not /etc/passwd. OSH behavior is different but better. | ||
This comment has been minimized.Show comment
Hide comment
lheckemann
Contributor
|
||
| dest_dir = util.GetHomeDir() | ||
| if dest_dir == '-': | ||
| old = mem.GetVar('OLDPWD', scope.GlobalOnly) | ||
| if old.tag == value_e.Undef: | ||
Is it really better though? I quite like for HOME to come from passwd on login, then everything else gets it from the environment variable. This allows overriding it consistently in a process subtree — simply by setting the environment variable — without root.