add comments

edoardoColi
edoardoColi 2 years ago
parent c15c8195a3
commit 088b029804

@ -224,7 +224,6 @@ function print_results()
### START EXECUTION ### START EXECUTION
_PROCESS_ID=$$ #save the process ID of the current shell _PROCESS_ID=$$ #save the process ID of the current shell
trap handle_sigint SIGINT #set up a trap for SIGINT
if [ $# -le 0 ] && [ -t 0 ]; then #if the number of arguments is less than or equal to 0 and we don't have a redirection. if [ $# -le 0 ] && [ -t 0 ]; then #if the number of arguments is less than or equal to 0 and we don't have a redirection.
error_msg $0 "Nothing has been passed to analyze" error_msg $0 "Nothing has been passed to analyze"
@ -249,18 +248,19 @@ fi
if ! [ -t 0 ]; then #checks if the descriptor is opened with a redirection, regardless of type of redirection used. if ! [ -t 0 ]; then #checks if the descriptor is opened with a redirection, regardless of type of redirection used.
if [ -p /dev/stdin ]; then #checks if there is a pipe redirection. Redirection from a command and not from a file. if [ -p /dev/stdin ]; then #checks if there is a pipe redirection. Redirection from a command and not from a file.
if [[ $_PROBE_FLAG == 'true' ]]; then #checks if we want to process a data stream (from tcpdump). if [[ $_PROBE_FLAG == 'true' ]]; then #checks if we want to process a data stream (from tcpdump).
trap handle_sigint SIGINT #set up a trap for SIGINT
lock_print=$(mktemp) #creates a unique temporary file name in /tmp/ folder. lock_print=$(mktemp) #creates a unique temporary file name in /tmp/ folder.
_FILE_REF="$_FILE3_TMP" _FILE_REF="$_FILE3_TMP"
sleep 2 #waiting to have something to analyze sleep 2 #waiting to have something to analyze
echo -ne "\033[2J\033[H" echo -ne "\033[2J\033[H" #The "\033[2J" sequence clear the terminal screen, the "\033[H" sequence moves the cursor to the top left corner of the screen.
while true while true
do do
filtering_away > $lock_print filtering_away > $lock_print
check_ret filtering_away $? check_ret filtering_away $?
print_results >> $lock_print print_results >> $lock_print
check_ret print_results $? check_ret print_results $?
echo -e "\033[2J\033[H" echo -e "\033[2J\033[H" #The "\033[2J" sequence clear the terminal screen, the "\033[H" sequence moves the cursor to the top left corner of the screen.
echo "$(cat $lock_print)" echo "$(cat $lock_print)" #The "$()" syntax is used to execute the command inside the parentheses and return the result as a string (used to handle print cases TO REVIEW)
done done
else else
_FILE_REF=$(mktemp) #creates a unique temporary file name in /tmp/ folder. _FILE_REF=$(mktemp) #creates a unique temporary file name in /tmp/ folder.

Loading…
Cancel
Save