Skip to content

Commit cb8e96d

Browse files
committed
! find-in-jars: add option -R, --no-find-progress, do not display responsive find progress
1 parent 2e3f185 commit cb8e96d

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

bin/find-in-jars

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,19 @@ die() {
4949
# https://unix.stackexchange.com/questions/299067
5050
[ -t 2 ] && readonly columns=$(stty size | awk '{print $2}')
5151
printResponsiveMessage() {
52-
[ -t 2 ] || return 0
52+
if ! $show_responsive || [ ! -t 2 ]; then
53+
return
54+
fi
5355

5456
local message="$*"
5557
# http://www.linuxforums.org/forum/red-hat-fedora-linux/142825-how-truncate-string-bash-script.html
5658
echo -n "$clear_line${message:0:columns}" >&2
5759
}
5860

5961
clearResponsiveMessage() {
60-
[ -t 2 ] || return 0
62+
if ! $show_responsive || [ ! -t 2 ]; then
63+
return
64+
fi
6165

6266
echo -n "$clear_line" >&2
6367
}
@@ -102,6 +106,7 @@ Output control:
102106
-a, --absolute-path always print absolute path of jar file
103107
-s, --separator specify the separator between jar file and zip entry.
104108
default is \`!'.
109+
-R, --no-find-progress do not display responsive find progress
105110
106111
Miscellaneous:
107112
-h, --help display this help and exit
@@ -121,6 +126,7 @@ declare -a args=()
121126
separator='!'
122127
regex_mode=-E
123128
use_absolute_path=false
129+
show_responsive=true
124130

125131
while (($# > 0)); do
126132
case "$1" in
@@ -132,11 +138,6 @@ while (($# > 0)); do
132138
extensions=(${extensions[@]:+"${extensions[@]}"} "$2")
133139
shift 2
134140
;;
135-
# support the typo option --seperator for compatibility
136-
-s | --separator | --seperator)
137-
separator="$2"
138-
shift 2
139-
;;
140141
-E | --extended-regexp)
141142
regex_mode=-E
142143
shift
@@ -161,6 +162,15 @@ while (($# > 0)); do
161162
use_absolute_path=true
162163
shift
163164
;;
165+
# support the typo option name --seperator for compatibility
166+
-s | --separator | --seperator)
167+
separator="$2"
168+
shift 2
169+
;;
170+
-R | --no-find-progress)
171+
show_responsive=false
172+
shift
173+
;;
164174
-h | --help)
165175
usage
166176
;;

docs/java.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ find-in-jars 'log4j\.properties' -s ' ' | awk '{print $2}'
441441
# 帮助信息
442442
$ find-in-jars -h
443443
Usage: find-in-jars [OPTION]... PATTERN
444+
444445
Find files in the jar files under specified directory,
445446
search jar files recursively(include subdirectory).
446447
The pattern default is *extended* regex.
@@ -470,6 +471,7 @@ Output control:
470471
-a, --absolute-path always print absolute path of jar file
471472
-s, --separator specify the separator between jar file and zip entry.
472473
default is `!'.
474+
-R, --no-find-progress do not display responsive find progress
473475
474476
Miscellaneous:
475477
-h, --help display this help and exit

0 commit comments

Comments
 (0)