Skip to content
Snippets Groups Projects
Commit 2dcc2969 authored by Fredrik Noring's avatar Fredrik Noring
Browse files

Better cwd handling (for relative paths).

Rev: bin/install.pike:1.66
Rev: lib/modules/Tools.pmod/Install.pmod:1.2
parent 65757d12
No related branches found
No related tags found
No related merge requests found
...@@ -870,6 +870,7 @@ int pre_install(array(string) argv) ...@@ -870,6 +870,7 @@ int pre_install(array(string) argv)
status1(""); status1("");
interactive=Tools.Install.Readline(); interactive=Tools.Install.Readline();
interactive->set_cwd("../");
write(" Welcome to the interactive "+version()+ write(" Welcome to the interactive "+version()+
" installation script.\n" " installation script.\n"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Common routines which are useful for various install scripts based on Pike. // 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 constant(getpwnam)
if(sizeof(path) && path[0] == '~') if(sizeof(path) && path[0] == '~')
...@@ -22,7 +22,7 @@ string make_absolute_path(string path) ...@@ -22,7 +22,7 @@ string make_absolute_path(string path)
#endif #endif
if(!sizeof(path) || path[0] != '/') if(!sizeof(path) || path[0] != '/')
return combine_path(getcwd(), "../", path); return combine_path(cwd || getcwd(), "./", path);
return path; return path;
} }
...@@ -92,7 +92,8 @@ class Readline ...@@ -92,7 +92,8 @@ class Readline
{ {
inherit Stdio.Readline; inherit Stdio.Readline;
int match_directories_only; private int match_directories_only;
private string cwd;
void trap_signal(int n) void trap_signal(int n)
{ {
...@@ -153,7 +154,7 @@ class Readline ...@@ -153,7 +154,7 @@ class Readline
string text = gettext(); string text = gettext();
int pos = getcursorpos(); 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 = array(string) files =
glob(path[-1]+"*", glob(path[-1]+"*",
get_dir(sizeof(path)>1? path[..sizeof(path)-2]*"/"+"/":".")||({})); get_dir(sizeof(path)>1? path[..sizeof(path)-2]*"/"+"/":".")||({}));
...@@ -187,6 +188,11 @@ class Readline ...@@ -187,6 +188,11 @@ class Readline
break; break;
} }
} }
void set_cwd(string _cwd)
{
cwd = _cwd;
}
void create(mixed ... args) void create(mixed ... args)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment