Hello!

For some reason POSIX X/Open Systems Interfaces option requires 'unlink'
utility to be present in operating system.  Sure, it does nothing that
'rm' doesn't already do, but given that 'unlink' is already used in some
scripts, I wonder if it would be benefitial for OpenBSD to include such
utility.

FWIW a simple implementation follows.


========================================================================
unlink.c
========================================================================
/*
 * Copyright (c) 2014 Dmitrij D. Czarkoff <czark...@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern char *__progname;

void  usage(void);

int
main(int argc, char **argv)
{
        setlocale(LC_ALL, "");

  if (argc != 2) {
    usage();
  } else if (unlink(*(argv+1))) {
    perror("unlink");
    return errno;
  }

  return 0;
}


void
usage(void)
{
        (void)fprintf(stderr, "usage: %s file\n", __progname);
        exit(1);
}


========================================================================
unlink.1
========================================================================
.\"
.\" Copyright (c) 2014 Dmitrij D. Czarkoff <czark...@gmail.com>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 26 2014 $
.Dt UNLINK 1
.Os
.Sh NAME
.Nm unlink
.Nd call the
.Xr unlink 2
function
.Sh SYNOPSIS
.Nm unlink
.Ar file
.Sh DESCRIPTION
The
.Nm
utility calls
.Xr unlink 2
function to remove a
.Ar file
specified on the command line.
.Pp
A user may need appropriate privileges to invoke the
.Nm
utility.
.Sh EXIT STATUS
.Ex -std unlink
.Sh SEE ALSO
.Xr link 1,
.Xr rm 1 ,
.Xr unlink 2
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2008
specification.
.Sh HISTORY
The
.Nm
utility first appeared in
.Ox 5.6 .


-- 
Dmitrij D. Czarkoff

Reply via email to