On Tue, Jun 18, 2024 at 12:10:03AM +0200, Ingo Schwarze wrote:
> Not a bug.
> But which one is preferable, test -L or test -h?
> 
> TLDR:
> If you follow David Korn, -L is the way to go.
> If you feel nostalgic about old SunOS, -h looks nicer.
> Both were standardized in POSIX Issue 6 (2001), with no preference given 
> there.
> Both always worked on OpenBSD, no matter which base system shell was used.
> In the OpenBSD ancestry, there was no difference in portability
> except between June 1993 and June 1995 (at most).
> 
> I admit that usually, when there are two equivalent syntaxes, deprecating
> one of them makes sense.  But in this case, with POSIX setting both in
> stone over 20 years ago, attempting to die on that particular molehill
> seems pointless to me.
> 
> Hence i suggest the patch below; OK?

ok jsg@

> 
> More complete history follows after the patch (just for the curious :-).
> This does not contradict what jmc@ wrote, but contains more information.

some extra notes on that below

> 
> Yours,
>   Ingo
> 
> 
> Index: test.1
> ===================================================================
> RCS file: /cvs/src/bin/test/test.1,v
> diff -u -p -r1.34 test.1
> --- test.1    10 Jun 2023 07:19:39 -0000      1.34
> +++ test.1    17 Jun 2024 21:22:30 -0000
> @@ -110,6 +110,8 @@ is set.
>  True if
>  .Ar file
>  exists and is a symbolic link.
> +Identical to
> +.Fl L .
>  .It Fl k Ar file
>  True if
>  .Ar file
> @@ -118,11 +120,8 @@ exists and its sticky bit is set.
>  True if
>  .Ar file
>  exists and is a symbolic link.
> -This operator is for compatibility purposes.
> -Do not rely on its existence;
> -use
> -.Fl h
> -instead.
> +Identical to
> +.Fl h .
>  .It Fl n Ar string
>  True if the length of
>  .Ar string
> Index: test.c
> ===================================================================
> RCS file: /cvs/src/bin/test/test.c,v
> diff -u -p -r1.20 test.c
> --- test.c    11 Oct 2022 13:40:38 -0000      1.20
> +++ test.c    17 Jun 2024 21:22:31 -0000
> @@ -110,7 +110,7 @@ struct t_op {
>       {"-t",  FILTT,  UNOP},
>       {"-z",  STREZ,  UNOP},
>       {"-n",  STRNZ,  UNOP},
> -     {"-h",  FILSYM, UNOP},          /* for backwards compat */
> +     {"-h",  FILSYM, UNOP},
>       {"-O",  FILUID, UNOP},
>       {"-G",  FILGID, UNOP},
>       {"-L",  FILSYM, UNOP},
> 
> 
>  ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 -----
> 
> History in OpenBSD ancestry:
> 
> OpenBSD:
> ksh(1) had both since the beginning, Aug 14, 1996 (pdksh 5.2.7).
> Before that, /bin/sh, which was ash, did not have a "test" builtin
> at all but used /bin/test instead, which also had both.
> csh(1) never had a "test" builtin.
> 
> NetBSD:
> /bin/test has -h since Feb 19, 1994 ("a la SunOS")
>               -L since Jun 30, 1994 ("from pdksh")
> 
> 4.4 BSD (June 1993) and 4.4BSD-Lite2 (June 1995):
> /bin/sh (ash) did not have a "test" builtin but used /bin/test instead.
> /bin/test had -h but not -L.
> 
> Version 7 AT&T UNIX (1979) and 4.3BSD-Reno (June 1990):
> /bin/sh (Bourne) did not have a "test" builtin but used /bin/test instead.
> /bin/test had neither -h nor -L.

"Dennis Ritchie implemented symlinks first, but doesn't take sole credit
for the idea, which came up in a group discussion at Berkeley."
https://groups.google.com/g/comp.unix.wizards/c/rkPBbdTELl0/m/skLmgp8G41QJ

v8 (Feb 1985) and later /bin/test has -L, no -h
from looking at tuhs archives

sunos 3.0 (Feb 1986) /bin/test has -h but no -L
bitsavers sun/sunos/3.0/800-1289-03A_Doing_More_with_UNIX_198602.pdf
pg 138

HP-UX (Oct 1987)
/bin/ksh has -L
bitsavers 
hp/9000_hpux/1987/97089-90062_198710_HP-UX_Concepts_Shells_and_Misc_Tools.pdf
pg 221

HP-UX 7.0 (Sep 1989) /bin/test has -h not no -L
bitsavers 
hp/9000_hpux/7.x/09000-90013_HP-UX_7.0_Reference_Vol_1_Section_1_Sep89.pdf
pg 691

SVR3 (1987) /bin/test has neither
bitsavers 
att/unix/System_V_Release_3/UNIX_System_V_Users_Reference_Manual_1987.pdf

SVR4 (1989) /bin/test has -h and -L
bitsavers 
att/unix/System_V_Release_4/0-13-947037-9_Unix_System_V_Rel4_Users_Reference_Manual_1990.pdf

csrg bin/test/operators.c rev 5.2 (May 1993) adds -h, but not -L
from looking a the sccs

Reply via email to