Re: `cp -l` doesn't work correctly on some macOS versions

2024-02-02 Thread Werner LEMBERG


Thanks to all who have answered!

>> I thought ln   || ln -s   was the standard
>> recipe here
>
> Yes, "cp -l" isn't required by POSIX and is not portable in
> general. For example, on AIX 7.1:
>
>   $ cp -l a b
>   cp: Not a recognized flag: l
>   Usage: cp [-fhipHILPU][-d|-e] [-r|-R] [-E{force|ignore|warn}] [--] src
>   target
>  or: cp [-fhipHILPU] [-d|-e] [-r|-R] [-E{force|ignore|warn}] [--] src1
>  ... srcN directory

Good to know.  I looked into the autoconf info files, section
'Limitations of usual tools', and 'cp -l' wasn't explictly mentioned,
so I assumed that it is portable...   Maybe it can be mentioned there
that it is not.

> Autoconf provides AC_PROG_LN_S, which is supposed to be even more
> portable than the recipe you gave.

I will go this route, thanks again.


Werner



Re: `cp -l` doesn't work correctly on some macOS versions

2024-02-02 Thread Paul Eggert

On 2/2/24 12:20, Russ Allbery wrote:

I thought ln   || ln -s   was the standard
recipe here


Yes, "cp -l" isn't required by POSIX and is not portable in general. For 
example, on AIX 7.1:


  $ cp -l a b
  cp: Not a recognized flag: l
  Usage: cp [-fhipHILPU][-d|-e] [-r|-R] [-E{force|ignore|warn}] [--] 
src target
 or: cp [-fhipHILPU] [-d|-e] [-r|-R] [-E{force|ignore|warn}] [--] 
src1 ... srcN directory


Autoconf provides AC_PROG_LN_S, which is supposed to be even more 
portable than the recipe you gave.




Re: `cp -l` doesn't work correctly on some macOS versions

2024-02-02 Thread Russ Allbery
Werner LEMBERG  writes:

> I'm shocked to read in

>   
> https://apple.stackexchange.com/questions/464706/why-do-i-get-bad-file-descriptor-when-copying-using-hardlink-flag

> that `cp -l` fails for recent macOS versions – a LilyPond user just
> confirmed that, too...

> What do you recommend to test for and/or to circumvent the issue?

I thought ln   || ln -s   was the standard
recipe here (in other words, fall back on symbolic links).  One has to be
very careful with how the paths are specified, though, because 
has a different meaning for ln -s than for ln.

(Note that even on modern systems, hard links are only reliably usable
within the same directory.  The example in the Stack Exchange question is
hard-linking to a different directory, which I would expect to fail in
lots of situations, such as on AFS file systems.)

-- 
Russ Allbery (ea...@eyrie.org) 



`cp -l` doesn't work correctly on some macOS versions

2024-02-02 Thread Werner LEMBERG

Folks,


I'm shocked to read in

  
https://apple.stackexchange.com/questions/464706/why-do-i-get-bad-file-descriptor-when-copying-using-hardlink-flag

that `cp -l` fails for recent macOS versions – a LilyPond user just
confirmed that, too...

What do you recommend to test for and/or to circumvent the issue?


Werner