0001-cmd-ln-change-same-reference-from-error-to-informati.patch (1901B)
- From c10e309cb4c029629c419d73a2b3f362b42ee65f Mon Sep 17 00:00:00 2001
- From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
- Date: Mon, 8 Sep 2025 19:55:00 +0200
- Subject: [PATCH] cmd/ln: change same reference from error to information
- POSIX (2008 and 2024) requires a message to standard error so has
- to be logged. Considering as the action is already done there's
- no need for an errorneous status.
- ---
- cmd/ln.c | 4 ++--
- test-cmd/ln.sh | 9 ++++++++-
- 2 files changed, 10 insertions(+), 3 deletions(-)
- diff --git a/cmd/ln.c b/cmd/ln.c
- index ad42486..5e866e1 100644
- --- a/cmd/ln.c
- +++ b/cmd/ln.c
- @@ -113,10 +113,10 @@ do_link(char *src, char *dest, int destfd)
- else if(src_stat.st_dev == dest_stat.st_dev && src_stat.st_ino == dest_stat.st_ino)
- {
- fprintf(stderr,
- - "ln: error: Source '%s' and destination '%s' refer to the same file\n",
- + "ln: info: Source '%s' and destination '%s' refer to the same file\n",
- src,
- dest);
- - return -1;
- + return 0;
- }
- if(unlink(dest) < 0)
- diff --git a/test-cmd/ln.sh b/test-cmd/ln.sh
- index ca0aa61..39ae619 100755
- --- a/test-cmd/ln.sh
- +++ b/test-cmd/ln.sh
- @@ -2,7 +2,7 @@
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- -plans=63
- +plans=67
- WD=$(dirname "$0")
- target="${WD}/../cmd/ln"
- . "${WD}/tap.sh"
- @@ -107,3 +107,10 @@ t_readlink()
- " -s /foo/bar/dest_broken_symlink ./
- t_args 'dest_broken_symlink:force' '' -sf /foo/bar/dest_broken_symlink ./
- t_cmd 'dest_broken_symlink:cleanup' '' rm dest_broken_symlink
- +
- +t_args same:create '' -s "$target" same
- +t_args --exit=1 same:no_force "ln: error: Destination 'same' already exists
- +" -s "$target" same
- +t_args same:force "ln: info: Source '$target' and destination 'same' refer to the same file
- +" -fs "$target" same
- +t_cmd same:cleanup '' rm same
- --
- 2.49.1