commit a2447c471d352eae8fcd272bab37291e52644ff3
parent f3fef43f6a2106d3f30d61ca9a9e3d32a70be864
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 4 Nov 2021 13:35:06 +0100
Add /usr/local to default HAREPATH
This also improves the formatting for hare version -v.
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/cmd/hare/subcmds.ha b/cmd/hare/subcmds.ha
@@ -10,6 +10,7 @@ use os::exec;
use os;
use path;
use strings;
+use unix::tty;
fn default_tags() []module::tag = {
return alloc([module::tag {
@@ -485,13 +486,34 @@ fn version(args: []str) void = {
};
fmt::println()!;
- match (os::getenv("HAREPATH")) {
- case void =>
- fmt::printfln("HAREPATH\t{}", HAREPATH)!;
- case s: str =>
- fmt::printf("HAREPATH\t{}", s)!;
- bufio::flush(os::stdout)!;
- fmt::errorln("\t(from environment)")!;
+ if (tty::isatty(os::stdout_file)) {
+ // Pretty print
+ match (os::getenv("HAREPATH")) {
+ case void =>
+ const items = strings::split(HAREPATH, ":");
+ defer free(items);
+ const items = strings::join("\n\t\t", items...);
+ defer free(items);
+ fmt::printfln("HAREPATH\t{}", items)!;
+ case env: str =>
+ fmt::printf("HAREPATH\t")!;
+ bufio::flush(os::stdout)!;
+ fmt::errorf("(from environment)")!;
+ const items = strings::split(env, ":");
+ defer free(items);
+ const items = strings::join("\n\t\t", items...);
+ defer free(items);
+ fmt::printfln("\n\t\t{}", items)!;
+ };
+ } else {
+ // Print for ease of machine parsing
+ const val = match (os::getenv("HAREPATH")) {
+ case void =>
+ yield HAREPATH;
+ case env: str =>
+ yield env;
+ };
+ fmt::printfln("HAREPATH\t{}", val)!;
};
};
};
diff --git a/config.example.mk b/config.example.mk
@@ -9,7 +9,8 @@ SRCDIR=$(PREFIX)/src
STDLIB=$(SRCDIR)/hare/stdlib
# Default HAREPATH
-HAREPATH=$(SRCDIR)/hare/stdlib:$(SRCDIR)/hare/third-party
+LOCALSRCDIR=/usr/local/src/hare
+HAREPATH=$(LOCALSRCDIR)/stdlib:$(LOCALSRCDIR)/third-party:$(SRCDIR)/hare/stdlib:$(SRCDIR)/hare/third-party
## Build configuration