@@ 1,6 1,6 @@
/* tyarn: minimal yarn implementation
*
- * Copyright © 2019 Richard Ipsum
+ * Copyright © 2019 - 2021 Richard Ipsum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ 97,8 97,16 @@ static int tyarn_path_exists(lua_State *L)
struct stat s;
const char *path = luaL_checkstring(L, 1);
- lua_pushboolean(L, (stat(path, &s) == -1 && errno == ENOENT) ? false : true);
+ if (stat(path, &s) == -1) {
+ if (errno != ENOENT) {
+ fprintf(stderr, "stat `%s': %s\n", path, strerror(errno));
+ exit(1);
+ }
+ lua_pushboolean(L, false); /* ENOENT */
+ return 1;
+ }
+ lua_pushboolean(L, true);
return 1;
}