mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-07 18:36:33 +00:00
fix: handle relative paths in CLI
This commit is contained in:
@@ -38,7 +38,10 @@ pub fn run(alloc: std.mem.Allocator) !u8 {
|
|||||||
|
|
||||||
// If a config path is passed, validate it, otherwise validate default configs
|
// If a config path is passed, validate it, otherwise validate default configs
|
||||||
if (opts.@"config-file") |config_path| {
|
if (opts.@"config-file") |config_path| {
|
||||||
try cfg.loadFile(alloc, config_path);
|
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||||
|
const abs_path = try std.fs.cwd().realpath(config_path, &buf);
|
||||||
|
|
||||||
|
try cfg.loadFile(alloc, abs_path);
|
||||||
|
|
||||||
if (!cfg._errors.empty()) {
|
if (!cfg._errors.empty()) {
|
||||||
try stdout.print("Config is not valid path={s}", .{config_path});
|
try stdout.print("Config is not valid path={s}", .{config_path});
|
||||||
|
@@ -1687,9 +1687,7 @@ pub fn loadIter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn loadFile(self: *Config, alloc: Allocator, path: []const u8) !void {
|
pub fn loadFile(self: *Config, alloc: Allocator, path: []const u8) !void {
|
||||||
const cwd = std.fs.cwd();
|
var file = try std.fs.cwd().openFile(path, .{});
|
||||||
|
|
||||||
var file = try cwd.openFile(path, .{});
|
|
||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
||||||
std.log.info("reading configuration file path={s}", .{path});
|
std.log.info("reading configuration file path={s}", .{path});
|
||||||
|
Reference in New Issue
Block a user