aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/cp/tests/Makefile2
-rwxr-xr-xbin/cp/tests/cp_test.sh2
-rw-r--r--bin/cp/tests/sparse.c73
-rw-r--r--bin/pwait/pwait.c30
-rw-r--r--bin/sh/Makefile7
-rw-r--r--bin/sh/dot.profile2
6 files changed, 19 insertions, 97 deletions
diff --git a/bin/cp/tests/Makefile b/bin/cp/tests/Makefile
index 3fa9ae8f0685..a1917ada8fbf 100644
--- a/bin/cp/tests/Makefile
+++ b/bin/cp/tests/Makefile
@@ -1,7 +1,5 @@
PACKAGE= tests
ATF_TESTS_SH= cp_test
-PROGS+= sparse
-BINDIR= ${TESTSDIR}
.include <bsd.test.mk>
diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
index 999993bfad67..fdf50d042f0b 100755
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -384,7 +384,7 @@ samefile_body()
file_is_sparse()
{
- atf_check ${0%/*}/sparse "$1"
+ atf_check -o match:"^[0-9]+-[0-9]" stat -h "$1"
}
files_are_equal()
diff --git a/bin/cp/tests/sparse.c b/bin/cp/tests/sparse.c
deleted file mode 100644
index 78957581a56c..000000000000
--- a/bin/cp/tests/sparse.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 2023 Klara, Inc.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <err.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-static bool verbose;
-
-/*
- * Returns true if the file named by its argument is sparse, i.e. if
- * seeking to SEEK_HOLE returns a different value than seeking to
- * SEEK_END.
- */
-static bool
-sparse(const char *filename)
-{
- off_t hole, end;
- int fd;
-
- if ((fd = open(filename, O_RDONLY)) < 0 ||
- (hole = lseek(fd, 0, SEEK_HOLE)) < 0 ||
- (end = lseek(fd, 0, SEEK_END)) < 0)
- err(1, "%s", filename);
- close(fd);
- if (end > hole) {
- if (verbose)
- printf("%s: hole at %zu\n", filename, (size_t)hole);
- return (true);
- }
- return (false);
-}
-
-static void
-usage(void)
-{
-
- fprintf(stderr, "usage: sparse [-v] file [...]\n");
- exit(EX_USAGE);
-}
-
-int
-main(int argc, char *argv[])
-{
- int opt, rv;
-
- while ((opt = getopt(argc, argv, "v")) != -1) {
- switch (opt) {
- case 'v':
- verbose = true;
- break;
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
- if (argc == 0)
- usage();
- rv = EXIT_SUCCESS;
- while (argc-- > 0)
- if (!sparse(*argv++))
- rv = EXIT_FAILURE;
- exit(rv);
-}
diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c
index 0fae22562607..a78c0bb84ca8 100644
--- a/bin/pwait/pwait.c
+++ b/bin/pwait/pwait.c
@@ -39,6 +39,7 @@
#include <err.h>
#include <errno.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -48,7 +49,6 @@
static void
usage(void)
{
-
fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n");
exit(EX_USAGE);
}
@@ -61,15 +61,15 @@ main(int argc, char *argv[])
{
struct itimerval itv;
struct kevent *e;
- int oflag, tflag, verbose;
- int i, kq, n, nleft, opt, status;
- long pid;
char *end, *s;
double timeout;
+ long pid;
+ int i, kq, n, nleft, opt, status;
+ bool oflag, tflag, verbose;
- oflag = 0;
- tflag = 0;
- verbose = 0;
+ oflag = false;
+ tflag = false;
+ verbose = false;
memset(&itv, 0, sizeof(itv));
while ((opt = getopt(argc, argv, "ot:v")) != -1) {
@@ -78,25 +78,31 @@ main(int argc, char *argv[])
oflag = 1;
break;
case 't':
- tflag = 1;
+ tflag = true;
errno = 0;
timeout = strtod(optarg, &end);
if (end == optarg || errno == ERANGE || timeout < 0) {
errx(EX_DATAERR, "timeout value");
}
- switch(*end) {
- case 0:
+ switch (*end) {
+ case '\0':
+ break;
case 's':
+ end++;
break;
case 'h':
timeout *= 60;
/* FALLTHROUGH */
case 'm':
timeout *= 60;
+ end++;
break;
default:
errx(EX_DATAERR, "timeout unit");
}
+ if (*end != '\0') {
+ errx(EX_DATAERR, "timeout unit");
+ }
if (timeout > 100000000L) {
errx(EX_DATAERR, "timeout value");
}
@@ -106,7 +112,7 @@ main(int argc, char *argv[])
(suseconds_t)(timeout * 1000000UL);
break;
case 'v':
- verbose = 1;
+ verbose = true;
break;
default:
usage();
@@ -134,7 +140,7 @@ main(int argc, char *argv[])
for (n = 0; n < argc; n++) {
s = argv[n];
/* Undocumented Solaris compat */
- if (!strncmp(s, "/proc/", 6)) {
+ if (strncmp(s, "/proc/", 6) == 0) {
s += 6;
}
errno = 0;
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index 916bb88b57fa..2b1eca8e4b31 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -69,11 +69,4 @@ token.h: mktokens
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
-beforeinstallconfig:
- rm -f ${DESTDIR}/.profile
-
-LINKMODE=${CONFMODE}
-afterinstallconfig:
- ${INSTALL_LINK} ${TAG_ARGS:D${TAG_ARGS},config} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
-
.include <bsd.prog.mk>
diff --git a/bin/sh/dot.profile b/bin/sh/dot.profile
index d27a2ae2fdbe..cba9bcf18ad9 100644
--- a/bin/sh/dot.profile
+++ b/bin/sh/dot.profile
@@ -1,6 +1,4 @@
#
-HOME=/root
-export HOME
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
TERM=${TERM:-xterm}