Issue error message if failing to change directory
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 19 Aug 2020 05:13:13 +0000 (07:13 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 19 Aug 2020 05:15:12 +0000 (07:15 +0200)
src/language/utilities/cd.c
src/language/utilities/include.c

index 9f7eaa1f02104c722c2516953d667f2f4437f5f7..ec5e7646f4ee1bba3fb610d9aa7f45fc7ba1d43c 100644 (file)
@@ -42,7 +42,7 @@ cmd_cd (struct lexer *lexer, struct dataset *ds UNUSED)
   if (-1 == chdir (path))
     {
       int err = errno;
   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;
     }
           strerror (err));
       goto error;
     }
index 19a5baa465dec0bb32b3b07e9d7e84a1009f1076..f518926de0dd346c3cc9f9a158e2abc323fa429b 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
 /* 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
 
    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);
           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);
             }
         }
               free (directory);
             }
         }