logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 7ece8e7ec02bc251c7a297771cdd3538bfc24fcb
parent 8889dd1c88ce54be02b14c64950ba170a808cc1b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 27 May 2021 05:42:34 +0200

bin/del: New program

Diffstat:

Mbin/Makefile.config4++--
Abin/del.122++++++++++++++++++++++
Abin/del.c24++++++++++++++++++++++++
3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/bin/Makefile.config b/bin/Makefile.config @@ -1,2 +1,2 @@ -EXE = args basename date dirname echo humanize lolcat mdate pwd range sizeof sname tty xcd -MAN1 = basename.1 date.1 dirname.1 humanize.1 lolcat.1 sname.1 +EXE = args basename date del dirname echo humanize lolcat mdate pwd range sizeof sname tty xcd +MAN1 = basename.1 date.1 del.1 dirname.1 humanize.1 lolcat.1 sname.1 diff --git a/bin/del.1 b/bin/del.1 @@ -0,0 +1,22 @@ +.\" Collection of Unix tools, comparable to coreutils +.\" Copyright 2017-2021 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +.\" SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only +.Dd 2021-05-13 +.Dt DEL 1 +.Os +.Sh NAME +.Nm del +.Nd delete any file +.Sh SYNOPSIS +.Nm +.Ar +.Sh DESCRIPTION +Simpler replacement to +.Xr rm 1 , +notably treating directories like any other file. +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr remove 3 +.Sh AUTHORS +.An Haelwenn (lanodan) Monnier Aq Mt contact@hacktivis.me diff --git a/bin/del.c b/bin/del.c @@ -0,0 +1,24 @@ +// Collection of Unix tools, comparable to coreutils +// Copyright 2021 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + +#define _POSIX_C_SOURCE 200809L +#include <errno.h> /* errno */ +#include <stdio.h> /* remove() */ +#include <string.h> /* strerror() */ + +int +main(int argc, char *argv[]) +{ + for(int i = 1; i < argc; i++) + { + if(remove(argv[i]) < 0) + { + // TODO: interact on write protection to force deletion + fprintf(stderr, "remove(%s) error: %s\n", argv[i], strerror(errno)); + return 1; + } + } + + return 0; +}