Date: Fri, 22 Feb 2002 15:33:54 +1100 (EST) From: Tim Robbins <tim@robbins.dropbear.id.au> To: FreeBSD-gnats-submit@freebsd.org Cc: freebsd-standards@freebsd.org Subject: link and unlink are not SUSv2-compliant as the manpage states Message-ID: <200202220433.g1M4XsV38018@descent.robbins.dropbear.id.au>
next in thread | raw e-mail | index | archive | help
>Submitter-Id: current-users >Originator: Tim Robbins >Organization: >Confidential: no >Synopsis: link and unlink are not SUSv2-compliant as the manpage states >Severity: non-critical >Priority: low >Category: bin >Class: sw-bug >Release: FreeBSD 4.5-STABLE i386 >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #4: Fri Feb 15 13:31:25 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: The manual pages for link and unlink, which are 'part of' ln and rm, and share the same manual pages, claim that these utilities are SUSV2 compliant. This is not the case. From The Single UNIX Specification, Version 2, XBD, Utility Argument Syntax: Guideline 10: "The argument -- should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the "-" character. The -- argument should not be used as an option or as an operand. Applications calling any utility with a first operand starting with - should usually specify --, as indicated by Guideline 10, to mark the end of the options ..." "... the Guidelines are rules for the standard utilities that claim conformance to them." link and unlink, therefore, should accept the "--" delimiter. Another problem is that when link's 2nd operand is a directory, it creates a link in that directory to the file named by the 1st operand, which is not correct. SUSV2 specifies that "link a b" is performs the equivalent of the function call link(a, b). unlink has the same problem: SUSV2 specifies it must call unlink() (which means it shouldn't treat whiteouts specially or try to reset immutable/append flags). >How-To-Repeat: N/A >Fix: Correct the manual pages by deleting the claims of SUSV2 conformance, or apply these patches that implement the correct behaviour. Index: ln/ln.c =================================================================== RCS file: /home/ncvs/src/bin/ln/ln.c,v retrieving revision 1.23 diff -u -r1.23 ln.c --- ln/ln.c 2002/02/02 06:44:35 1.23 +++ ln/ln.c 2002/02/22 04:00:47 @@ -85,11 +85,14 @@ else ++p; if (strcmp(p, "link") == 0) { - if (argc == 3) { - linkf = link; - exit(linkit(argv[1], argv[2], 0)); - } else + argv++, argc--; + if (argc > 0 && strncmp(*argv, "--", 2) == 0) + argv++, argc--; + if (argc != 2) usage(); + if (link(argv[0], argv[1]) != 0) + err(1, "%s to %s", argv[0], argv[1]); + exit(0); } while ((ch = getopt(argc, argv, "fhinsv")) != -1) Index: rm/rm.c =================================================================== RCS file: /home/ncvs/src/bin/rm/rm.c,v retrieving revision 1.36 diff -u -r1.36 rm.c --- rm/rm.c 2002/02/14 01:59:47 1.36 +++ rm/rm.c 2002/02/22 04:07:03 @@ -95,11 +95,14 @@ else ++p; if (strcmp(p, "unlink") == 0) { - if (argc == 2) { - rm_file(&argv[1]); - exit(eval); - } else + argv++, argc--; + if (argc > 0 && strncmp(*argv, "--", 2) == 0) + argv++, argc--; + if (argc != 1) usage(); + if (unlink(*argv) != 0) + err(1, "%s", *argv); + exit(0); } Pflag = rflag = 0; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202220433.g1M4XsV38018>