make(1): add tests for edge cases in parsing the command line

This commit is contained in:
rillig 2020-11-14 17:33:51 +00:00
parent c066253900
commit a9f48205a2
2 changed files with 37 additions and 3 deletions

View File

@ -1 +1,19 @@
make -:
usage: make [-BeikNnqrstWwX]
[-C directory] [-D variable] [-d flags] [-f makefile]
[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]
[-V variable] [-v variable] [variable=value] [target ...]
*** Error code 2 (ignored)
make -- -VAR=value -f /dev/null
make: don't know how to make -f (continuing)
`/dev/null' is up to date.
make -?
usage: make [-BeikNnqrstWwX]
[-C directory] [-D variable] [-d flags] [-f makefile]
[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]
[-V variable] [-v variable] [variable=value] [target ...]
*** Error code 2 (ignored)
exit status 0 exit status 0

View File

@ -1,8 +1,24 @@
# $NetBSD: opt.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ # $NetBSD: opt.mk,v 1.3 2020/11/14 17:33:51 rillig Exp $
# #
# Tests for the command line options. # Tests for the command line options.
# TODO: Implementation # TODO: Implementation
all: .MAKEFLAGS: -d0 # make stdout line-buffered
@:;
all: .IGNORE
# Just to see how the custom argument parsing code reacts to a syntax
# error. The colon is used in the options string, marking an option
# that takes arguments. It is not an option by itself, though.
${MAKE} -:
@echo
# See whether a '--' stops handling of command line options, like in
# standard getopt programs. Yes, it does, and it treats the '-f' as
# a target to be created.
${MAKE} -- -VAR=value -f /dev/null
@echo
# This is the normal way to print the usage of a command.
${MAKE} -?
@echo