From f47ebc4b1cb3795666eca992b903c4c2c9bbcc25 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Mon, 28 Nov 2016 12:40:55 -0800 Subject: [PATCH] builtin cd: Handle unset HOME. --- src/builtin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 91c560114..3f1dccbf0 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -2461,7 +2461,10 @@ static int builtin_cd(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } if (!got_cd_path) { - if (errno == ENOTDIR) { + if (dir_in.missing_or_empty()) { + streams.err.append_format(_(L"%ls: $HOME not set\n"), argv[0]); + } + else if (errno == ENOTDIR) { streams.err.append_format(_(L"%ls: '%ls' is not a directory\n"), argv[0], dir_in.c_str()); } else if (errno == ENOENT) {