logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: c10e309cb4c029629c419d73a2b3f362b42ee65f
parent c1a011a7640e2756bb68cfddd3afdff24cce3551
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  8 Sep 2025 19:55:00 +0200

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.

Diffstat:

Mcmd/ln.c4++--
Mtest-cmd/ln.sh9++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git 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 @@ -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 @@ ln: error: Destination './/dest_broken_symlink' already exists " -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