summaryrefslogtreecommitdiffstats
path: root/bin/rm/rm.c
diff options
context:
space:
mode:
authorsheldonh <sheldonh@FreeBSD.org>1999-12-20 16:13:47 +0000
committersheldonh <sheldonh@FreeBSD.org>1999-12-20 16:13:47 +0000
commit61c79b122e44f58607ac5f393bcf9b4a7a821178 (patch)
treeed04b5fbbf6e1897e6a52c236a7e251ae7ef66c5 /bin/rm/rm.c
parentfb59e40253fef0113a40fb946389c81e296d4068 (diff)
downloadFreeBSD-src-61c79b122e44f58607ac5f393bcf9b4a7a821178.zip
FreeBSD-src-61c79b122e44f58607ac5f393bcf9b4a7a821178.tar.gz
Add link(1) and unlink(1) as special cases of ln(1) and rm(1)
respectively, in accordance with SUSv2. This differs from the approach taken in NetBSD, but provides less obscure error messages in at least the EISDIR case and does not take up additional disk space for new binaries. PR: 13071 PR: 13074 Requested by: James Howard <howardjp@wam.umd.edu>
Diffstat (limited to 'bin/rm/rm.c')
-rw-r--r--bin/rm/rm.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index 7d7de4b..a4a3c96 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -86,6 +86,24 @@ main(argc, argv)
char *argv[];
{
int ch, rflag;
+ char *p;
+
+ /*
+ * Test for the special case where the utility is called as
+ * "unlink", for which the functionality provided is greatly
+ * simplified.
+ */
+ if ((p = rindex(argv[0], '/')) == NULL)
+ p = argv[0];
+ else
+ ++p;
+ if (strcmp(p, "unlink") == 0) {
+ if (argc == 2) {
+ rm_file(&argv[1]);
+ exit(eval);
+ } else
+ usage();
+ }
Pflag = rflag = 0;
while ((ch = getopt(argc, argv, "dfiPRrvW")) != -1)
@@ -472,6 +490,8 @@ void
usage()
{
- (void)fprintf(stderr, "usage: rm [-f | -i] [-dPRrvW] file ...\n");
+ (void)fprintf(stderr, "%s\n%s\n",
+ "usage: rm [-f | -i] [-dPRrvW] file ...",
+ " unlink file");
exit(EX_USAGE);
}
OpenPOWER on IntegriCloud