From 1a0e5ec166218b256cd9954dde9f6c0bfac9c0fd Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 2 May 2010 08:18:29 +0000 Subject: [PATCH] The /cd command now handles getcwd() failing (eg if the current directory has been removed). git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@85 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 ++ source/commands.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index cfaedb7..74e4bd9 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2c01] +* Handle error return from getcwd() in /cd (caf). + * Fix alloca warnings on freebsd. (caf) * Fix memory leak in banlist.c. (caf) diff --git a/source/commands.c b/source/commands.c index 120ebc2..baf87cf 100644 --- a/source/commands.c +++ b/source/commands.c @@ -5190,8 +5190,6 @@ BUILT_IN_COMMAND(cd) *expand; char buffer[BIG_BUFFER_SIZE + 1]; - - *buffer = 0; if ((arg = new_next_arg(args, &args)) != NULL && *arg) { if ((expand = expand_twiddle(arg)) != NULL) @@ -5206,12 +5204,14 @@ BUILT_IN_COMMAND(cd) } else { - bitchsay("CD No such dir %s", arg); + bitchsay("CD: %s No such directory", arg); return; } } - getcwd(buffer, BIG_BUFFER_SIZE); - bitchsay("Current directory: %s", buffer); + if (getcwd(buffer, BIG_BUFFER_SIZE)) + bitchsay("Current directory: %s", buffer); + else + bitchsay("CD: %s", strerror(errno)); } BUILT_IN_COMMAND(exec_cmd)