1
0

more changes

This commit is contained in:
dtb 2023-08-17 17:51:47 -04:00
parent 4f7d204f5a
commit aa110975ae
3 changed files with 13 additions and 21 deletions

View File

@ -8,11 +8,10 @@ argued \(en check for arguments
Argued exits successfully if any arguments are provided, and unsuccessfully otherwise. Argued exits successfully if any arguments are provided, and unsuccessfully otherwise.
.SH STANDARDS
Argued is not described in POSIX.1-2017.
Argued's function may be performed on a purely POSIX system with test(1).
.SH COPYRIGHT .SH COPYRIGHT
Public domain. Public domain.
.SH SEE ALSO
str(1), test(1)

View File

@ -5,33 +5,29 @@ set -e
str isvalue "$MANUAL_DIR" \ str isvalue "$MANUAL_DIR" \
|| MANUAL_DIR=/usr/manual || MANUAL_DIR=/usr/manual
argv0="$0" # normalization
! str isvalue "$1" || str isvalue "$3" \ ! str isvalue "$1" || str isvalue "$3" \
&& printf "Usage: %s [name] (section)\n" "$argv0" 1>&2 \ && printf "Usage: %s [name] (section)\n" "$argv0" 1>&2 \
&& exit 1 \ && exit 1 \
|| true || \
str isvalue "$2" && ! test -e "$MANUAL_DIR/$2/$1" \ str isvalue "$2" && ! test -e "$MANUAL_DIR/$2/$1" \
&& printf "%s: %s: No manual entry in section %s\n" "$0" "$1" "$2" \ && printf "%s: %s: No manual entry in section %s\n" "$0" "$1" "$2" \
1>&2 \ 1>&2 \
&& exit 1 \ && exit 1 \
|| true || \
str isvalue "$2" \ str isvalue "$2" \
&& PAGE="$MANUAL_DIR/$2/$1" \ && PAGE="$MANUAL_DIR/$2/$1" \
|| for d in "$MANUAL_DIR"/* || for d in "$MANUAL_DIR"/*
do test -e "$d/$1" && PAGE="$d/$1" do test -e "$d/$1" && PAGE="$d/$1"
done done
# lookup + execution
! str isvalue "$PAGE" \ ! str isvalue "$PAGE" \
&& printf "%s: %s: No manual entry\n" "$0" "$1" 1>&2 \ && printf "%s: %s: No manual entry\n" "$0" "$1" 1>&2 \
&& exit 1 \ && exit 1 \
|| true || \
! str isvalue "$SECTION_DIR" \ ! str isvalue "$SECTION_DIR" \
&& printf "%s: %s: No manual entry\n" "$argv0" "$1" 1>&2 \ && printf "%s: %s: No manual entry\n" "$argv0" "$1" 1>&2 \
&& exit 1 \ && exit 1 \
|| true || \
<"$PAGE" groff -t -e -mandoc -Tascii <"$PAGE" groff -t -e -mandoc -Tascii

View File

@ -3,13 +3,10 @@ TARGETS = str
all: $(TARGETS) all: $(TARGETS)
str: %.c str: str.c
$(CC) -o $@ $@.c $(CC) -DINCLUDE_ISVALUE=1 -o $@ $@.c
clean: clean:
$(RM) $(TARGETS) $(RM) $(TARGETS)
sane: str.c ../include/sysexits.h .PHONY: all clean
$(CC) -DDONT_USE_SYSTEM_SYSEXITS -o str str.c
.PHONY: all clean sane