ref: 64dbbe0f4dbd1354374b926eae6b03201b1ad161
parent: 84fa11317ae6dafc90f72b330447c188ca00d462
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Jan 5 16:54:59 EST 2025
path-cwd: throw an io error if getcwd failed
--- a/builtins.c
+++ b/builtins.c
@@ -366,11 +366,12 @@
argcount(nargs, 1);
if(nargs == 0){
char buf[1024];
- getcwd(buf, sizeof(buf));
+ if(getcwd(buf, sizeof(buf)) == nil)
+ lerrorf(FL_IOError, "could not get current dir");
return string_from_cstr(buf);
}
char *ptr = tostring(args[0]);
- if(chdir(ptr))
+ if(chdir(ptr) != 0)
lerrorf(FL_IOError, "could not cd to %s", ptr);
return FL_void;
}