summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--txr.15
-rw-r--r--txr.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 91520a8e..4ad3ebbb 100644
--- a/txr.1
+++ b/txr.1
@@ -41444,6 +41444,11 @@ is restored.
During the processing of the profile file (see Interactive Profile File),
the variable is bound to the name of that file.
+.coNP Variable @ txr-path
+.desc
+This variable holds the absolute path name of the directory which
+holds the executable file of the current process.
+
.SH* INTERACTIVE LISTENER
.SS* Overview
diff --git a/txr.c b/txr.c
index aa1a5eaa..5243c941 100644
--- a/txr.c
+++ b/txr.c
@@ -267,6 +267,12 @@ static val maybe_sysroot(val exepart)
sysroot_path = sub_str(prog_path, 0, neg(length(exepart))));
}
+static val dirname(val path)
+{
+ val rslash = rpos(chr('/'), path, nil, nil);
+ return if3(rslash, sub_str(path, zero, succ(rslash)), path);
+}
+
static val substitute_basename(val edited_path, val source_path)
{
val lslash = rpos(chr('/'), edited_path, nil, nil);
@@ -316,6 +322,7 @@ static void sysroot_init(void)
toint(lit(TXR_VER), nil));
reg_varl(intern(lit("txr-version"), user_package),
toint(lit(TXR_VER), nil));
+ reg_varl(intern(lit("txr-path"), user_package), dirname(prog_path));
}
static int license(void)