From 45d3412004e556e37e4e3d48869677b59700fc74 Mon Sep 17 00:00:00 2001 From: Fredrik Noring <noring@nocrew.org> Date: Fri, 1 Sep 2000 16:44:28 +0200 Subject: [PATCH] Better cwd handling (for relative paths). Rev: bin/install.pike:1.68 Rev: lib/modules/Tools.pmod/Install.pmod:1.3 --- bin/install.pike | 29 ++--------------------------- lib/modules/Tools.pmod/Install.pmod | 5 +++++ 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/bin/install.pike b/bin/install.pike index fbcdd166a4..b31edb5103 100644 --- a/bin/install.pike +++ b/bin/install.pike @@ -642,31 +642,6 @@ done exit(0); } -string make_absolute_path(string path) -{ -#if constant(getpwnam) - if(sizeof(path) && path[0] == '~') - { - string user, newpath; - sscanf(path, "~%s/%s", user, newpath); - - if(user && sizeof(user)) - { - array a = getpwnam(user); - if(a && sizeof(a) >= 7) - return combine_path(a[5], newpath); - } - - return combine_path(getenv("HOME"), path[2..]); - } -#endif - - if(!sizeof(path) || path[0] != '/') - return combine_path(getcwd(), "../", path); - - return path; -} - #ifdef USE_GTK object window1; object vbox1; @@ -904,7 +879,7 @@ int pre_install(array(string) argv) // werror("PREFIX: %O\n",prefix); // if(!vars->prefix) prefix=interactive->edit_directory(prefix,"Install prefix: "); - prefix = make_absolute_path(prefix); + prefix = interactive->absolute_path(prefix); if(!vars->pike_name) { @@ -920,7 +895,7 @@ int pre_install(array(string) argv) #endif } - bin_path = make_absolute_path(bin_path); + bin_path = interactive->absolute_path(bin_path); write("\n"); confirm = diff --git a/lib/modules/Tools.pmod/Install.pmod b/lib/modules/Tools.pmod/Install.pmod index 2f8cc8352a..de5e4178b5 100644 --- a/lib/modules/Tools.pmod/Install.pmod +++ b/lib/modules/Tools.pmod/Install.pmod @@ -189,6 +189,11 @@ class Readline } } + string absolute_path(string path) + { + return make_absolute_path(path, cwd && combine_path(getcwd(), cwd)); + } + void set_cwd(string _cwd) { cwd = _cwd; -- GitLab