From f6bce395681577e2c43fb120ecc057dca1b57be9 Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Fri, 23 Jan 2026 15:08:57 +0000 Subject: [PATCH] Fail early on CD --- src/lib/eval.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/eval.ml b/src/lib/eval.ml index e81e3c7..dbb4a8f 100644 --- a/src/lib/eval.ml +++ b/src/lib/eval.ml @@ -900,7 +900,11 @@ module Make (S : Types.State) (E : Types.Exec) = struct match path with | Some p -> let fp = Fpath.append cwd (Fpath.v p) in - Exit.zero @@ S.set_cwd ctx.state fp + if Eio.Path.is_directory (ctx.fs / Fpath.to_string fp) then + Exit.zero @@ S.set_cwd ctx.state fp + else + Exit.nonzero_msg ~exit_code:1 ctx.state + "cd: not a directory: %a" Fpath.pp fp | None -> ( match Eunix.find_env "HOME" with | None -> Exit.nonzero_msg ctx.state "HOME not set" -- 2.51.2