diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-04 14:31:18 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-04 15:54:09 +0900 |
commit | 977252421baac7a4b42a914c48bc7ae29ec934ee (patch) | |
tree | 144bcd9d2deac90ee4041e1f99c0b1969a06544d /tool | |
parent | 8da7f4abc779c6549833d718336d75aac98494b8 (diff) |
ifchange: check the number of arguments
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/ifchange | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tool/ifchange b/tool/ifchange index 050c8d8f26..5af41e0156 100755 --- a/tool/ifchange +++ b/tool/ifchange @@ -3,6 +3,18 @@ # Used in generating revision.h via Makefiles. +help() { + cat <<HELP +usage: $0 [options] target new-file +options: + --timestamp[=file] touch timestamp file. (default: prefixed with ".time". + under the directory of the target) + --keep[=suffix] keep old file with suffix. (default: '.old') + --empty assume unchanged if the new file is empty. + --color[=always|auto|never] colorize output. +HELP +} + set -e timestamp= keepsuffix= @@ -10,6 +22,10 @@ empty= color=auto until [ $# -eq 0 ]; do case "$1" in + --) + shift + break; + ;; --timestamp) timestamp=. ;; @@ -34,6 +50,14 @@ until [ $# -eq 0 ]; do --debug) set -x ;; + --help) + help + exit + ;; + --*) + echo "$0: unknown option: $1" 1>&2 + exit 1 + ;; *) break ;; @@ -41,6 +65,11 @@ until [ $# -eq 0 ]; do shift done +if [ "$#" != 2 ]; then + help + exit 1 +fi + target="$1" temp="$2" if [ "$temp" = - ]; then |