commit: 7efb9b47340165b450ec1671f6b5afb148c3eef4
parent 3863a47d7621e2dc7e49ca53a9617f48ae0e3df6
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 16 Nov 2024 07:01:31 +0100
chdir() after parsing options
Diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/main.ha b/main.ha
@@ -371,6 +371,8 @@ export fn main() void = {
defer getopt::finish(&cmd);
defer free(excludes);
+ let opt_d = "";
+
for (let i = 0z; i < len(cmd.opts); i += 1) {
const opt = cmd.opts[i];
switch (opt.0) {
@@ -379,13 +381,7 @@ export fn main() void = {
case 'e' =>
append(excludes, opt.1);
case 'd' =>
- match (os::chdir(opt.1)) {
- case let e: fs::error =>
- fmt::fatalf("deblob: os::chdir({}): {}",
- opt.1, fs::strerror(e));
- case void =>
- void;
- };
+ opt_d = opt.1;
case 'n' =>
noop = true;
case =>
@@ -393,6 +389,17 @@ export fn main() void = {
};
};
+
+ if(opt_d != "")
+ {
+ match (os::chdir(opt_d)) {
+ case let e: fs::error =>
+ fmt::fatalf("deblob: os::chdir({}): {}", opt_d, fs::strerror(e));
+ case void =>
+ void;
+ };
+ };
+
fmt::println(":: Checking for blobs")!;
const ret = check_dir(".");