changeset 28503:f480103d8333

Fix unlink() calls in package m-files for new syntax (bug #57830) * pkg.m, build.m, uninstall.m: Call "[~] = unlink (...)" so that error is not thrown and scripts continue even if there was no file to unlink.
author Rik <rik@octave.org>
date Thu, 25 Jun 2020 18:20:03 -0700
parents 39e6308e4251
children a39a46b4cd4e
files scripts/pkg/pkg.m scripts/pkg/private/build.m scripts/pkg/private/uninstall.m
diffstat 3 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/pkg/pkg.m	Thu Jun 25 15:22:37 2020 -0700
+++ b/scripts/pkg/pkg.m	Thu Jun 25 18:20:03 2020 -0700
@@ -567,7 +567,7 @@
                  global_list, global_install);
 
       unwind_protect_cleanup
-        cellfun ("unlink", local_files);
+        [~] = cellfun ("unlink", local_files);
         if (exist (tmp_dir, "file"))
           rmdir (tmp_dir, "s");
         endif
--- a/scripts/pkg/private/build.m	Thu Jun 25 15:22:37 2020 -0700
+++ b/scripts/pkg/private/build.m	Thu Jun 25 18:20:03 2020 -0700
@@ -95,7 +95,7 @@
 
     ## Currently does nothing because gzip() removes the original tar
     ## file but that should change in the future (bug #43431).
-    unlink (tar_path);
+    [~] = unlink (tar_path);
   endfor
 
 endfunction
--- a/scripts/pkg/private/uninstall.m	Thu Jun 25 15:22:37 2020 -0700
+++ b/scripts/pkg/private/uninstall.m	Thu Jun 25 18:20:03 2020 -0700
@@ -32,8 +32,8 @@
                     global_list, global_install)
 
   ## Get the list of installed packages.
-  [local_packages, global_packages] = installed_packages(local_list,
-                                                         global_list);
+  [local_packages, global_packages] = installed_packages (local_list,
+                                                          global_list);
   if (global_install)
     installed_pkgs_lst = {local_packages{:}, global_packages{:}};
   else
@@ -145,8 +145,8 @@
 
     ## Write a new ~/.octave_packages.
     if (global_install)
-      if (length (remaining_packages) == 0)
-        unlink (global_list);
+      if (numel (remaining_packages) == 0)
+        [~] = unlink (global_list);
       else
         global_packages = save_order (remaining_packages);
         if (ispc)
@@ -157,8 +157,8 @@
         save (global_list, "global_packages");
       endif
     else
-      if (length (remaining_packages) == 0)
-        unlink (local_list);
+      if (numel (remaining_packages) == 0)
+        [~] = unlink (local_list);
       else
         local_packages = save_order (remaining_packages);
         if (ispc)