logo

utils-extra

Collection of extra tools for Unixes
commit: 1a1b191f3285d23d9ea766172b52485c500b1eee
parent 0d988edcea360e9dfd559a060dfc6614b1726c4b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 26 Sep 2023 17:40:04 +0200

cmd/errno: Remove, conflicts with moreutils

Diffstat:

Dcmd/errno.122----------------------
Dcmd/errno.c42------------------------------------------
Mtest-cmd/Kyuafile1-
Dtest-cmd/errno51---------------------------------------------------
4 files changed, 0 insertions(+), 116 deletions(-)

diff --git a/cmd/errno.1 b/cmd/errno.1 @@ -1,22 +0,0 @@ -.\" utils-extra: Collection of extra tools for Unixes -.\" Copyright 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> -.\" SPDX-License-Identifier: MPL-2.0 -.Dd 2022-04-19 -.Dt ENV 1 -.Os -.Sh NAME -.Nm errno -.Nd print errno message for a value -.Sh SYNOPSIS -.Nm -.Ar value -.Sh DESCRIPTION -.Nm -shall print the errno message associated with -.Ar value . -.Sh EXIT STATUS -.Ex -std -.Sh STANDARDS -No applicable one known. -.Sh AUTHORS -.An Haelwenn (lanodan) Monnier Aq Mt contact@hacktivis.me diff --git a/cmd/errno.c b/cmd/errno.c @@ -1,42 +0,0 @@ -// utils-extra: Collection of extra tools for Unixes -// SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> -// SPDX-License-Identifier: MPL-2.0 - -#include <errno.h> // errno -#include <stdio.h> // puts, perror -#include <stdlib.h> // strtol -#include <string.h> // strerror - -int -main(int argc, char *argv[]) -{ - if(argc != 2) - { - puts("usage: errno <number>"); - return 1; - } - - errno = 0; - - int err = (int)(strtol(argv[1], NULL, 10)); - if(errno != 0) - { - perror("errno: strtol"); - return 1; - } - - errno = 0; - char *msg = strerror(err); - if(errno != 0) - { - perror("errno: strerror"); - return 1; - } - - if(puts(msg) < 0) - { - return 1; - } - - return 0; -} diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile @@ -10,7 +10,6 @@ basedir = fs.dirname(fs.dirname(current_kyuafile())) -- atf_test_program{name="pat", required_files=basedir.."/cmd/pat", timeout=1} atf_test_program{name="args", required_files=basedir.."/cmd/args", timeout=1} atf_test_program{name="del", required_files=basedir.."/cmd/del", timeout=1} -atf_test_program{name="errno", required_files=basedir.."/cmd/errno", timeout=1} atf_test_program{name="humanize", required_files=basedir.."/cmd/humanize", timeout=1} atf_test_program{name="lolcat", required_files=basedir.."/cmd/lolcat", timeout=1} atf_test_program{name="mdate", required_files=basedir.."/cmd/mdate", timeout=1} diff --git a/test-cmd/errno b/test-cmd/errno @@ -1,51 +0,0 @@ -#!/usr/bin/env atf-sh -# SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> -# SPDX-License-Identifier: MPL-2.0 - -atf_test_case simple -simple_body() { - atf_check -o "inline:Operation not permitted\n" ../cmd/errno 1 -} - -atf_test_case noargs -noargs_body() { - atf_check -s exit:1 -o "inline:usage: errno <number>\n" ../cmd/errno -} - -atf_test_case devfull -devfull_body() { - has_glibc && atf_expect_fail "glibc ignoring write errors for puts()" - [ "$(uname -s)" = "NetBSD" ] && atf_expect_fail "NetBSD ignoring write errors for puts()" - [ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD ignoring write errors for puts()" - - atf_check -s exit:1 sh -c '../cmd/errno 1 >/dev/full' -} - -atf_test_case einval -einval_body() { - if has_glibc; then - atf_check -s exit:0 -o "inline:Unknown error -1\n" ../cmd/errno -1 - elif has_musl; then - atf_check -s exit:0 -o "inline:No error information\n" ../cmd/errno -1 - else - atf_check -s exit:1 -e "inline:errno: strerror: Invalid argument\n" ../cmd/errno -1 - fi -} - -atf_test_case erange -erange_body() { - # 36893488147419103232 = 2^65 - atf_check -s 'exit:1' -e not-empty ../cmd/errno 36893488147419103232 -} - -atf_init_test_cases() { - cd "$(atf_get_srcdir)" || exit 1 - - . ../test_functions.sh - - atf_add_test_case simple - atf_add_test_case noargs - atf_add_test_case devfull - atf_add_test_case einval - atf_add_test_case erange -}