You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this pattern from perl:
satisfy xxx or die
Yes, `or` is the boolean operator of perl
In shell, `or` is `||`
if you get familiar with this pattern, it's very readable!
# check the directory of append-file(-a) mode, create if not exsit.
205
205
if [ -n"$append_file" ];then
206
206
if [ -e"$append_file" ];then
207
-
[ !-f"$append_file" ] && fatal "Error: $append_file(specified by option -a, for storing run output files) exists but is not a file!"
208
-
[ !-w"$append_file" ] && fatal "Error: file $append_file(specified by option -a, for storing run output files) exists but is not writable!"
207
+
[ -f"$append_file" ] || die "$append_file(specified by option -a, for storing run output files) exists but is not a file!"
208
+
[ -w"$append_file" ] || die "file $append_file(specified by option -a, for storing run output files) exists but is not writable!"
209
209
else
210
210
append_file_dir="$(dirname "$append_file")"
211
211
if [ -e"$append_file_dir" ];then
212
-
[ !-d"$append_file_dir" ] && fatal "Error: directory $append_file_dir(specified by option -a, for storing run output files) exists but is not a directory!"
213
-
[ !-w"$append_file_dir" ] && fatal "Error: directory $append_file_dir(specified by option -a, for storing run output files) exists but is not writable!"
212
+
[ -d"$append_file_dir" ] || die "directory $append_file_dir(specified by option -a, for storing run output files) exists but is not a directory!"
213
+
[ -w"$append_file_dir" ] || die "directory $append_file_dir(specified by option -a, for storing run output files) exists but is not writable!"
214
214
else
215
-
mkdir -p "$append_file_dir"||fatal "Error: fail to create directory $append_file_dir(specified by option -a, for storing run output files)!"
215
+
mkdir -p "$append_file_dir"||die "fail to create directory $append_file_dir(specified by option -a, for storing run output files)!"
216
216
fi
217
217
fi
218
218
fi
219
219
220
220
# check store directory(-S) mode, create directory if not exsit.
221
221
if [ -n"$store_dir" ];then
222
222
if [ -e"$store_dir" ];then
223
-
[ !-d"$store_dir" ] && fatal "Error: $store_dir(specified by option -S, for storing output files) exists but is not a directory!"
224
-
[ !-w"$store_dir" ] && fatal "Error: directory $store_dir(specified by option -S, for storing output files) exists but is not writable!"
223
+
[ -d"$store_dir" ] || die "$store_dir(specified by option -S, for storing output files) exists but is not a directory!"
224
+
[ -w"$store_dir" ] || die "directory $store_dir(specified by option -S, for storing output files) exists but is not writable!"
225
225
else
226
-
mkdir -p "$store_dir"||fatal "Error: fail to create directory $store_dir(specified by option -S, for storing output files)!"
226
+
mkdir -p "$store_dir"||die "fail to create directory $store_dir(specified by option -S, for storing output files)!"
[ -f"$jstack_path" ] ||fatal "Error: $jstack_path is NOT found!"
236
-
[ -x"$jstack_path" ] ||fatal "Error: $jstack_path is NOT executalbe!"
235
+
[ -f"$jstack_path" ] ||die "$jstack_path is NOT found!"
236
+
[ -x"$jstack_path" ] ||die "$jstack_path is NOT executalbe!"
237
237
elif which jstack &> /dev/null;then
238
238
jstack_path="`which jstack`"
239
239
else
240
-
[ -z"$JAVA_HOME" ] && fatal "Error: jstack not found on PATH and No JAVA_HOME setting! Use -s option set jstack path manually."
241
-
[ -f"$JAVA_HOME/bin/jstack" ] ||fatal "Error: jstack not found on PATH and \$JAVA_HOME/bin/jstack($JAVA_HOME/bin/jstack) file does NOT exists! Use -s option set jstack path manually."
242
-
[ -x"$JAVA_HOME/bin/jstack" ] ||fatal "Error: jstack not found on PATH and \$JAVA_HOME/bin/jstack($JAVA_HOME/bin/jstack) is NOT executalbe! Use -s option set jstack path manually."
240
+
[ -n"$JAVA_HOME" ] || die "jstack not found on PATH and No JAVA_HOME setting! Use -s option set jstack path manually."
241
+
[ -f"$JAVA_HOME/bin/jstack" ] ||die "jstack not found on PATH and \$JAVA_HOME/bin/jstack($JAVA_HOME/bin/jstack) file does NOT exists! Use -s option set jstack path manually."
242
+
[ -x"$JAVA_HOME/bin/jstack" ] ||die "jstack not found on PATH and \$JAVA_HOME/bin/jstack($JAVA_HOME/bin/jstack) is NOT executalbe! Use -s option set jstack path manually."
0 commit comments