Skip to content

Commit 24c8378

Browse files
committed
add seperator option for find-in-jars
1 parent 867a1b5 commit 24c8378

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

docs/java.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,15 @@ Find file in the jar files under specified directory(recursive, include subdirec
358358
The pattern default is *extended* regex.
359359
360360
Example:
361-
find-in-jars 'log4j\.properties'
362-
find-in-jars '^log4j(\.properties|\.xml)$' # search file log4j.properties/log4j.xml at zip root
363-
find-in-jars 'log4j\.properties$' -d /path/to/find/directory
364-
find-in-jars 'log4j\.properties' -d /path/to/find/dir1 -d /path/to/find/dir2
361+
find-in-jars 'log4j\.properties'
362+
find-in-jars '^log4j(\.properties|\.xml)$' # search file log4j.properties/log4j.xml at zip root
363+
find-in-jars 'log4j\.properties$' -d /path/to/find/directory
364+
find-in-jars 'log4j\.properties' -d /path/to/find/dir1 -d /path/to/find/dir2
365365
366366
Options:
367367
-d, --dir the directory that find jar files, default is current directory.
368368
this option can specify multiply times to find in multiply directories.
369+
-s, --seperator seperator for jar file and file entry, default is `!'.
369370
-E, --extended-regexp PATTERN is an extended regular expression (*default*)
370371
-F, --fixed-strings PATTERN is a set of newline-separated strings
371372
-G, --basic-regexp PATTERN is a basic regular expression

find-in-jars

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Example:
3030
Options:
3131
-d, --dir the directory that find jar files, default is current directory.
3232
this option can specify multiply times to find in multiply directories.
33+
-s, --seperator seperator for jar file and file entry, default is \`!'.
3334
-E, --extended-regexp PATTERN is an extended regular expression (*default*)
3435
-F, --fixed-strings PATTERN is a set of newline-separated strings
3536
-G, --basic-regexp PATTERN is a basic regular expression
@@ -56,6 +57,10 @@ while [ $# -gt 0 ]; do
5657
dirs=("${dirs[@]}" "$2")
5758
shift 2
5859
;;
60+
-s|--seperator)
61+
seperator="$2"
62+
shift 2
63+
;;
5964
-E|--extended-regexp)
6065
regex_mode=-E
6166
shift
@@ -100,6 +105,7 @@ while [ $# -gt 0 ]; do
100105
esac
101106
done
102107
dirs=${dirs:-.}
108+
seperator="${seperator:-!}"
103109

104110
[ "${#args[@]}" -eq 0 ] && { echo "No find file pattern!" 1>&2 ; usage 1; }
105111
[ "${#args[@]}" -gt 1 ] && { echo "More than 1 file pattern!" 1>&2 ; usage 1; }
@@ -207,8 +213,8 @@ while read jar_file; do
207213
clearResponsiveMessage
208214

209215
$is_console &&
210-
echo "$ec[1;31m${jar_file}$eend$ec[1;32m"\!"$eend${file}" ||
211-
echo "${jar_file}"\!"${file}"
216+
echo "$ec[1;31m${jar_file}${eend}${ec}[1;32m${seperator}${eend}${file}" ||
217+
echo "${jar_file}${seperator}${file}"
212218
done
213219

214220
clearResponsiveMessage

0 commit comments

Comments
 (0)