Skip to content

Commit e742ccf

Browse files
Merge pull request #323 from MortezaBashsiz/dev
Fix check dependencies
2 parents 9604299 + 57b0e30 commit e742ccf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

bash/cfScanner.sh

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# REVISION: nomadzzz, armgham, beh-rouz, amini8, mahdibahramih, armineslami
1818
#===============================================================================
1919

20+
export TOP_PID=$$
21+
2022
# Function fncLongIntToStr
2123
# converts IP in long integer format to a string
2224
fncLongIntToStr() {
@@ -378,20 +380,19 @@ export -f fncCheckIPList
378380
# Function fncCheckDpnd
379381
# Check for dipendencies
380382
function fncCheckDpnd {
381-
osVersion="Linux"
383+
osVersion="NULL"
382384
if [[ "$(uname)" == "Linux" ]]; then
385+
command -v jq >/dev/null 2>&1 || { echo >&2 "I require 'jq' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
386+
command -v parallel >/dev/null 2>&1 || { echo >&2 "I require 'parallel' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
387+
command -v bc >/dev/null 2>&1 || { echo >&2 "I require 'bc' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
388+
command -v timeout >/dev/null 2>&1 || { echo >&2 "I require 'timeout' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
383389
osVersion="Linux"
384-
command -v jq >/dev/null 2>&1 || { echo >&2 "I require 'jq' but it's not installed. Please install it and try again."; exit 1; }
385-
command -v parallel >/dev/null 2>&1 || { echo >&2 "I require 'parallel' but it's not installed. Please install it and try again."; exit 1; }
386-
command -v bc >/dev/null 2>&1 || { echo >&2 "I require 'bc' but it's not installed. Please install it and try again."; exit 1; }
387-
command -v timeout >/dev/null 2>&1 || { echo >&2 "I require 'timeout' but it's not installed. Please install it and try again."; exit 1; }
388-
389390
elif [[ "$(uname)" == "Darwin" ]];then
391+
command -v jq >/dev/null 2>&1 || { echo >&2 "I require 'jq' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
392+
command -v parallel >/dev/null 2>&1 || { echo >&2 "I require 'parallel' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
393+
command -v bc >/dev/null 2>&1 || { echo >&2 "I require 'bc' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
394+
command -v gtimeout >/dev/null 2>&1 || { echo >&2 "I require 'gtimeout' but it's not installed. Please install it and try again."; kill -s 1 "$TOP_PID"; }
390395
osVersion="Mac"
391-
command -v jq >/dev/null 2>&1 || { echo >&2 "I require 'jq' but it's not installed. Please install it and try again."; exit 1; }
392-
command -v parallel >/dev/null 2>&1 || { echo >&2 "I require 'parallel' but it's not installed. Please install it and try again."; exit 1; }
393-
command -v bc >/dev/null 2>&1 || { echo >&2 "I require 'bc' but it's not installed. Please install it and try again."; exit 1; }
394-
command -v gtimeout >/dev/null 2>&1 || { echo >&2 "I require 'gtimeout' but it's not installed. Please install it and try again."; exit 1; }
395396
fi
396397
echo "$osVersion"
397398
}

0 commit comments

Comments
 (0)