From: John Darrington Date: Wed, 19 Aug 2020 05:13:13 +0000 (+0200) Subject: Issue error message if failing to change directory X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=045c554e54937f8bc6813537f864edc5c683a0a9;p=pspp Issue error message if failing to change directory --- diff --git a/src/language/utilities/cd.c b/src/language/utilities/cd.c index 9f7eaa1f02..ec5e7646f4 100644 --- a/src/language/utilities/cd.c +++ b/src/language/utilities/cd.c @@ -42,7 +42,7 @@ cmd_cd (struct lexer *lexer, struct dataset *ds UNUSED) if (-1 == chdir (path)) { int err = errno; - msg (SE, _("Cannot change directory to %s: %s "), path, + msg (SE, _("Cannot change directory to %s: %s"), path, strerror (err)); goto error; } diff --git a/src/language/utilities/include.c b/src/language/utilities/include.c index 19a5baa465..f518926de0 100644 --- a/src/language/utilities/include.c +++ b/src/language/utilities/include.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2007, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2007, 2010, 2011, 2020 Free Software Foundation, Inc. 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 @@ -166,7 +166,15 @@ do_insert (struct lexer *lexer, struct dataset *ds, enum variant variant) if (cd) { char *directory = dir_name (filename); - chdir (directory); + int ret = chdir (directory); + if (0 != ret) + { + int err = errno; + msg (SE, _("Cannot change directory to %s: %s"), directory, + strerror (err)); + status = CMD_FAILURE; + } + free (directory); } }