Skip to content

Commit

Permalink
Use libc.realpath() instead of os.path.realpath().
Browse files Browse the repository at this point in the history
We found out from implementing 'readlink -f' that these functions are
different.  This doesn't change the test results, so we might as well
simplify the code and depend on fewer things.

This might change as a result of fixing issue #182 anyway.
  • Loading branch information
Andy Chu committed Sep 20, 2018
1 parent 87157ed commit 6276dce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from osh import lex
from osh import match

import libc
from _devbuild.gen import osh_help # generated file

value_e = runtime.value_e
Expand Down Expand Up @@ -538,7 +539,7 @@ def Cd(argv, mem, dir_stack):
# '-L' is the default behavior; no need to check it
# TODO: ensure that if multiple flags are provided, the *last* one overrides
# the others
pwd = os.path.realpath(dest_dir) if arg.P else dest_dir
pwd = libc.realpath(dest_dir) if arg.P else dest_dir
state.SetGlobalString(mem, 'PWD', pwd)

dir_stack.Reset() # for pushd/popd/dirs
Expand Down Expand Up @@ -653,7 +654,7 @@ def Pwd(argv, mem):
# TODO: ensure that if multiple flags are provided, the *last* one overrides
# the others
if arg.P:
pwd = os.path.realpath(pwd)
pwd = libc.realpath(pwd)
print(pwd)
return 0

Expand Down

0 comments on commit 6276dce

Please sign in to comment.