diff options
author | Jari Aalto <jari.aalto@cante.net> | 1999-02-19 17:11:39 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:52 +0000 |
commit | b72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (patch) | |
tree | b9899162338c2ff3fd83a8aef8831cb119e85cd7 /builtins/cd.def | |
parent | bc4cd23ce958feda898c618215f94d8a4e8f4ffa (diff) | |
download | android_external_bash-b72432fdcc59300c6fe7c9d6c8a31ad3447933f5.tar.gz android_external_bash-b72432fdcc59300c6fe7c9d6c8a31ad3447933f5.tar.bz2 android_external_bash-b72432fdcc59300c6fe7c9d6c8a31ad3447933f5.zip |
Imported from ../bash-2.03.tar.gz.
Diffstat (limited to 'builtins/cd.def')
-rw-r--r-- | builtins/cd.def | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/builtins/cd.def b/builtins/cd.def index 76ef14b..b6bf692 100644 --- a/builtins/cd.def +++ b/builtins/cd.def @@ -140,22 +140,20 @@ bindpwd (no_symlinks) else dirname = get_working_directory ("cd"); - bind_variable ("OLDPWD", get_string_value ("PWD")); - old_anm = array_needs_making; + pwdvar = get_string_value ("PWD"); + + tvar = bind_variable ("OLDPWD", pwdvar); + if (old_anm == 0 && array_needs_making && exported_p (tvar)) + { + update_export_env_inplace ("OLDPWD=", 7, pwdvar); + array_needs_making = 0; + } + tvar = bind_variable ("PWD", dirname); - /* This is an efficiency hack. If PWD is exported, we will need to - remake the exported environment every time we change directories. - If there is no other reason to make the exported environment, just - update PWD in place and mark the exported environment as no longer - needing a remake. */ if (old_anm == 0 && array_needs_making && exported_p (tvar)) { - pwdvar = xmalloc (STRLEN (dirname) + 5); /* 5 = "PWD" + '=' + '\0' */ - strcpy (pwdvar, "PWD="); - if (dirname) - strcpy (pwdvar + 4, dirname); - add_or_supercede_exported_var (pwdvar, 0); + update_export_env_inplace ("PWD=", 4, dirname); array_needs_making = 0; } @@ -243,7 +241,7 @@ cd_builtin (list) { /* Find directory in $CDPATH. */ path_index = 0; - while ((path = extract_colon_unit (cdpath, &path_index))) + while (path = extract_colon_unit (cdpath, &path_index)) { /* OPT is 1 if the path element is non-empty */ opt = path[0] != '\0'; |