Просмотр исходного кода

u-a: Do not check if linknames can be updated if --force is in use

The action is going to proceed in any case, no point wasting resources
doing the checks. Also this removes a possible point of non-overridable
failure.
Guillem Jover лет назад: 15
Родитель
Сommit
81412e6445
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      utils/update-alternatives.c

+ 4 - 1
utils/update-alternatives.c

@@ -1629,6 +1629,9 @@ alternative_can_replace_path(const char *linkname)
 	struct stat st;
 	bool replace_link;
 
+	if (opt_force)
+		return true;
+
 	errno = 0;
 	if (lstat(linkname, &st) == -1) {
 		if (errno != ENOENT)
@@ -1638,7 +1641,7 @@ alternative_can_replace_path(const char *linkname)
 		replace_link = S_ISLNK(st.st_mode);
 	}
 
-	return (replace_link || opt_force);
+	return replace_link;
 }
 
 static void