@@ -16,6 +16,8 @@ readonly PROG="`basename "$0"`"
1616usage () {
1717 [ -n " $1 " -a " $1 " != 0 ] && local out=/dev/stderr || local out=/dev/stdout
1818
19+ [ $# -gt 1 ] && { echo " $2 " ; echo ; } > $out
20+
1921 > $out cat << EOF
2022Usage: ${PROG} [OPTION]... PATTERN
2123Find file in the jar files under specified directory(recursive, include subdirectory).
@@ -25,7 +27,7 @@ Example:
2527 ${PROG} 'log4j\.properties'
2628 ${PROG} '^log4j\.(properties|xml)$' # search file log4j.properties/log4j.xml at zip root
2729 ${PROG} 'log4j\.properties$' -d /path/to/find/directory
28- ${PROG} 'log4j\.properties' -d /path/to/find/dir1 -d / path/to/find/dir2
30+ ${PROG} 'log4j\.properties' -d /path/to/find/dir1 -d path/to/find/dir2
2931 ${PROG} 'log4j\.properties' -e jar -e zip
3032 ${PROG} 'log4j\.properties' -s ' <-> '
3133
@@ -106,9 +108,7 @@ while [ $# -gt 0 ]; do
106108 break
107109 ;;
108110 -* )
109- echo " ${PROG} : unrecognized option '$1 '" 1>&2
110- echo 1>&2
111- usage 2;
111+ usage 2 " ${PROG} : unrecognized option '$1 '"
112112 ;;
113113 * )
114114 args=(" ${args[@]} " " $1 " )
@@ -120,8 +120,8 @@ dirs=${dirs:-.}
120120extension=${extension:- jar}
121121seperator=" ${seperator:-! } "
122122
123- [ " ${# args[@]} " -eq 0 ] && { echo " No find file pattern!" 1>&2 ; usage 1 ; }
124- [ " ${# args[@]} " -gt 1 ] && { echo " More than 1 file pattern!" 1>&2 ; usage 1 ; }
123+ [ " ${# args[@]} " -eq 0 ] && usage 1 " No find file pattern!"
124+ [ " ${# args[@]} " -gt 1 ] && usage 1 " More than 1 file pattern!"
125125readonly pattern=" ${args[0]} "
126126
127127# convert dirs to Absolute Path.
0 commit comments