Subject: Re: bug#52115: Suggestion: LN command should swap TARGET and LINK_NAME if LINK_NAME already exists

From: Ulf Zibis <[email-masked]>
Date: Mon, 29 Nov 2021 11:34:33 +0100

Am 27.11.21 um 09:41 schrieb Paul Eggert:
> On 11/25/21 15:10, Warren Parad wrote:
>> except mv(1) and cp(1) are both "FROM" and then "TO", but ln is backwards
>> from thi, it is "TO" then "FROM"
>
> No, ln is exactly like mv and cp here: the source is the first argument, and the destination is the second.
The problem is the possible confusion between "target" as result of the command and as link target.

> If this isn't clear, perhaps we should make the documentation clearer; but we shouldn't change ln's behavior, as many people and programs rely on the current behavior, and the current behavior is more logical once you understand how file systems work.
Agreed.
I would like to change the order of the forms from:
Usage: ln [OPTION]... [-T] TARGET LINK_NAME
   or:  ln [OPTION]... TARGET
   or:  ln [OPTION]... TARGET... DIRECTORY
   or:  ln [OPTION]... -t DIRECTORY TARGET...
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
By default, each destination (name of new link) should not already exist.
When creating hard links, each TARGET must exist.  Symbolic links
can hold arbitrary text; if later resolved, a relative link is
interpreted in relation to its parent directory.
to:
Usage: ln [OPTION]... TARGET
   or:  ln [OPTION]... [-T] TARGET LINK_NAME
   or:  ln [OPTION]... TARGET... DIRECTORY
   or:  ln [OPTION]... -t DIRECTORY TARGET...
1st form: Create a link to TARGET with same name in the current directory.
2nd form: Create a link to TARGET with the name LINK_NAME.
3rd and 4th forms: Create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
By default, each destination (name of new link) should not already exist.
When creating hard links, each TARGET must exist.  Symbolic links
can hold arbitrary text; if later resolved, a relative link is
interpreted in relation to its parent directory.

I think, for beginners it would be less confusing, if the most simple form would be the first.

Additionally we could add "with the same name" in the than 1st form.

Additionally we could shorten "In the 1st form," to "1st form:".

Also for me the existence of the 3rd for is the most confusing, as it enforces the perplexing -T option.

-Ulf