summaryrefslogtreecommitdiff
path: root/lang/lush/patches/patch-ac
blob: 172751ac8b6645d174a47258c03539a3362e10dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$NetBSD: patch-ac,v 1.2 2012/07/22 01:08:24 dholland Exp $

Fix handling of user home directory in runtime.

--- lsh/libc/shell.lsh~	2005-03-08 15:14:44.000000000 -0500
+++ lsh/libc/shell.lsh	2008-08-17 02:40:12.000000000 -0400
@@ -241,7 +241,18 @@
 
 #? shell-home
 ;; user home directory
-(defvar shell-home (getenv "HOME"))
+(defvar shell-home nil)
+
+;; get-shell-home
+;; fetch user home directory
+;; (merely initializing shell-home gets the compile-time $HOME, which is wrong)
+;; If shell-home isn't set, set it from $HOME; otherwise return it.
+;; This is suboptimal because shell-home will be nil until (cd) is run,
+;; but it's better than having shell-home contain the pkgsrc dummy homedir.
+(de shell.get-shell-home ()
+  (if (not shell-home)
+      (setq shell-home (getenv "HOME"))
+    shell-home))
 
 #? shell-dirstack
 ;; directory stack manipulated by pushd and popd
@@ -262,7 +273,7 @@
 #? (cd [<d>])
 ;; change current directory to <d>, or to 
 ;; user home if <p> is not present.
-(de cd (&optional p) (if p (chdir p) (chdir shell-home)))
+(de cd (&optional p) (if p (chdir p) (chdir (get-shell-home))))
 
 #? (pushd <d>)
 ;; Temporarily change current directory to <d>.