summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-11 19:51:46 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-11 21:19:04 +0200
commit06a6f7b4582fcf0209d0b78b267ca5daab2a6731 (patch)
treebc5ae2ddab47ba53c64464ab83c03a9deca6f345 /bin
parent8c691b0ce92fb079154544d79673f678195d98f1 (diff)
grepc, grepc.1: -h: Add option to print the usage message.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grepc50
1 files changed, 38 insertions, 12 deletions
diff --git a/bin/grepc b/bin/grepc
index ad60951..3d78821 100755
--- a/bin/grepc
+++ b/bin/grepc
@@ -1,10 +1,34 @@
#!/bin/sh
-if [ $# -ne 1 ]; then
- >&2 echo "Usage: $0 IDENTIFIER";
- exit 1;
-fi;
+grepc_usage()
+{
+ echo "Usage: $0 [OPTION] IDENTIFIER";
+}
+
+
+grepc_parse_cmd()
+{
+ while getopts "h" opt; do
+ case "$opt" in
+ h)
+ grepc_usage;
+ exit 0;
+ ;;
+ ?)
+ grepc_usage >&2;
+ exit 1;
+ ;;
+ esac;
+ done;
+ shift $(($OPTIND-1));
+
+ if [ $# -ne 1 ]; then
+ grepc_usage >&2;
+ exit 1;
+ fi;
+ identifier=$1;
+}
grepc_find_files()
@@ -180,15 +204,17 @@ grepc_type()
main()
{
- grepc_find_files "$1";
+ grepc_parse_cmd $@;
+
+ grepc_find_files "$identifier";
- grepc_macro "$1";
- grepc_enum_constant "$1";
- grepc_func "$1";
- grepc_linux "$1";
- grepc_glibc "$1";
- grepc_type "$1";
+ grepc_macro "$identifier";
+ grepc_enum_constant "$identifier";
+ grepc_func "$identifier";
+ grepc_linux "$identifier";
+ grepc_glibc "$identifier";
+ grepc_type "$identifier";
}
-main "$1";
+main $@;