ref: 40c1498b2d4ef5a7a39dfad83812f03be0c6453e
parent: 204b05d910ebcaec8af1fe62e8bbd19f3f41932a
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Nov 24 12:44:22 EST 2016
Add homedir extraction. This is not robust at all.
--- a/lib/fileutil/bld.sub
+++ b/lib/fileutil/bld.sub
@@ -1,5 +1,7 @@
lib fileutil =
walk.myr
+ homedir.myr
+
lib ../sys:sys
lib ../std:std
;;
--- /dev/null
+++ b/lib/fileutil/homedir.myr
@@ -1,0 +1,21 @@
+use std
+
+pkg fileutil =
+ const homedir : (-> byte[:])
+;;
+
+const homedir = {
+ match std.getenv("HOME")
+ | `std.Some h: -> h
+ | `std.None: /* nothing */
+ ;;
+
+ /* 9front uses $home */
+ match std.getenv("home")
+ | `std.Some h: -> h
+ | `std.None: /* nothing */
+ ;;
+
+ /* really, we should read from /etc/passwd or ldap/nss */
+ -> ""
+}