From 2dcc29690137a41321d7253918c8c16ee3632ebc Mon Sep 17 00:00:00 2001 From: Fredrik Noring <noring@nocrew.org> Date: Fri, 1 Sep 2000 13:12:56 +0200 Subject: [PATCH] Better cwd handling (for relative paths). Rev: bin/install.pike:1.66 Rev: lib/modules/Tools.pmod/Install.pmod:1.2 --- bin/install.pike | 1 + lib/modules/Tools.pmod/Install.pmod | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/install.pike b/bin/install.pike index 3c561933b8..fd95ff5ee1 100644 --- a/bin/install.pike +++ b/bin/install.pike @@ -870,6 +870,7 @@ int pre_install(array(string) argv) status1(""); interactive=Tools.Install.Readline(); + interactive->set_cwd("../"); write(" Welcome to the interactive "+version()+ " installation script.\n" diff --git a/lib/modules/Tools.pmod/Install.pmod b/lib/modules/Tools.pmod/Install.pmod index 2f90c93b09..2f8cc8352a 100644 --- a/lib/modules/Tools.pmod/Install.pmod +++ b/lib/modules/Tools.pmod/Install.pmod @@ -2,7 +2,7 @@ // Common routines which are useful for various install scripts based on Pike. // -string make_absolute_path(string path) +string make_absolute_path(string path, string|void cwd) { #if constant(getpwnam) if(sizeof(path) && path[0] == '~') @@ -22,7 +22,7 @@ string make_absolute_path(string path) #endif if(!sizeof(path) || path[0] != '/') - return combine_path(getcwd(), "../", path); + return combine_path(cwd || getcwd(), "./", path); return path; } @@ -92,7 +92,8 @@ class Readline { inherit Stdio.Readline; - int match_directories_only; + private int match_directories_only; + private string cwd; void trap_signal(int n) { @@ -153,7 +154,7 @@ class Readline string text = gettext(); int pos = getcursorpos(); - array(string) path = make_absolute_path(text[..pos-1])/"/"; + array(string) path = make_absolute_path(text[..pos-1], cwd)/"/"; array(string) files = glob(path[-1]+"*", get_dir(sizeof(path)>1? path[..sizeof(path)-2]*"/"+"/":".")||({})); @@ -187,6 +188,11 @@ class Readline break; } } + + void set_cwd(string _cwd) + { + cwd = _cwd; + } void create(mixed ... args) { -- GitLab