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)
status1("");
interactive=Tools.Install.Readline();
interactive->set_cwd("../");
write(" Welcome to the interactive "+version()+
" installation script.\n"
......
......@@ -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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment