Tools ; fix checkers
This commit is contained in:
parent
01e71ddc61
commit
d7bb4c4a4e
|
@ -46,7 +46,6 @@ gsl_post_min_ID=10
|
||||||
gsl_post_min_size=800
|
gsl_post_min_size=800
|
||||||
|
|
||||||
# Init log datas
|
# Init log datas
|
||||||
gsl_log_a=' ~ '
|
|
||||||
gsl_log_e='Err'
|
gsl_log_e='Err'
|
||||||
gsl_log_w='War'
|
gsl_log_w='War'
|
||||||
gsl_log_i='Inf'
|
gsl_log_i='Inf'
|
||||||
|
|
|
@ -90,7 +90,7 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
log|-L)
|
log|-L)
|
||||||
[[ -z `grep '[^[:space:]]' "$gsl_file_logs"` ]] \
|
[[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \
|
||||||
&& echo "# No logs to show. File is empty." \
|
&& echo "# No logs to show. File is empty." \
|
||||||
&& exit
|
&& exit
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ gsl__logs_print() {
|
||||||
#4: Infos
|
#4: Infos
|
||||||
#5: File
|
#5: File
|
||||||
printf '%s %s\t%s\t%s\t%s\t%s\n' \
|
printf '%s %s\t%s\t%s\t%s\t%s\n' \
|
||||||
"`date +%F' ~ '%T`" \
|
"`date +%F' '%T`" \
|
||||||
"$1" \
|
"$1" \
|
||||||
"$2" \
|
"$2" \
|
||||||
"$3" \
|
"$3" \
|
||||||
|
@ -27,7 +27,6 @@ printf '%s %s\t%s\t%s\t%s\t%s\n' \
|
||||||
# Show logs from file with filters
|
# Show logs from file with filters
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
gsl__logs_show() {
|
gsl__logs_show() {
|
||||||
clear
|
|
||||||
|
|
||||||
# Choices are important, but let's give priority
|
# Choices are important, but let's give priority
|
||||||
[[ "$gsl_logs_inf" ]] \
|
[[ "$gsl_logs_inf" ]] \
|
||||||
|
@ -41,12 +40,6 @@ clear
|
||||||
&& gsl_log_show_session="Last session" \
|
&& gsl_log_show_session="Last session" \
|
||||||
|| gsl_log_show_session="All"
|
|| gsl_log_show_session="All"
|
||||||
|
|
||||||
gsl_logs_infos=`
|
|
||||||
printf '%s\n%s\n%s\n' \
|
|
||||||
"Logs : $gsl_log_show_session" \
|
|
||||||
"Filter: $gsl_logs_filter" \
|
|
||||||
"Search: $gsl_logs_search"`
|
|
||||||
|
|
||||||
# Last session show or not
|
# Last session show or not
|
||||||
if [[ "$gsl_logs_last_session" ]];then
|
if [[ "$gsl_logs_last_session" ]];then
|
||||||
gsl_log_start_line=`
|
gsl_log_start_line=`
|
||||||
|
@ -54,8 +47,6 @@ if [[ "$gsl_logs_last_session" ]];then
|
||||||
| tail -1 \
|
| tail -1 \
|
||||||
| awk -F: '{print $1}'`
|
| awk -F: '{print $1}'`
|
||||||
|
|
||||||
printf '%s\n \n' "$gsl_logs_infos"
|
|
||||||
|
|
||||||
awk -v sl="$gsl_log_start_line" \
|
awk -v sl="$gsl_log_start_line" \
|
||||||
'NR >= sl' \
|
'NR >= sl' \
|
||||||
"$gsl_file_logs" \
|
"$gsl_file_logs" \
|
||||||
|
@ -63,8 +54,6 @@ if [[ "$gsl_logs_last_session" ]];then
|
||||||
| grep -Ei "$gsl_logs_search" \
|
| grep -Ei "$gsl_logs_search" \
|
||||||
| column -t -s$'\t'
|
| column -t -s$'\t'
|
||||||
else
|
else
|
||||||
printf '%s\n' "$gsl_logs_infos"
|
|
||||||
|
|
||||||
while read -r "gsl_log_content"
|
while read -r "gsl_log_content"
|
||||||
do
|
do
|
||||||
# Let's read clear sessions
|
# Let's read clear sessions
|
||||||
|
|
|
@ -26,9 +26,7 @@ gsl__post_check_abbr
|
||||||
echo -ne "\r\033[2K: Searching for LINKs.."
|
echo -ne "\r\033[2K: Searching for LINKs.."
|
||||||
gsl__post_check_links
|
gsl__post_check_links
|
||||||
|
|
||||||
echo
|
echo -ne "\r\033[2K"
|
||||||
#echo -ne "\r\033[2K"
|
|
||||||
|
|
||||||
# End of checkers : show logs for war and err
|
# End of checkers : show logs for war and err
|
||||||
[[ "$gsl_checker_war" ]] \
|
[[ "$gsl_checker_war" ]] \
|
||||||
&& gsl log -s -w
|
&& gsl log -s -w
|
||||||
|
@ -199,7 +197,6 @@ if (( "$gsl_post_p_open_nbr" == 0 ));then
|
||||||
"Missing content: ( and ) at begining lines" \
|
"Missing content: ( and ) at begining lines" \
|
||||||
"${PWD}/$gsl_post"
|
"${PWD}/$gsl_post"
|
||||||
gsl_checker_err=true
|
gsl_checker_err=true
|
||||||
gsl_checker_err=true
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -320,36 +317,27 @@ fi
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
gsl__post_check_abbr() {
|
gsl__post_check_abbr() {
|
||||||
gsl_post_stat_abbr=0
|
gsl_post_stat_abbr=0
|
||||||
while read -r "gsl_header_abbr"
|
while read -r "gsl_header_content_line"
|
||||||
do
|
do
|
||||||
gsl_post_abbr_s=`gsl__get_header_field 1 "$gsl_header_abbr"`
|
# Get & Check HEADER CONTENT
|
||||||
gsl_post_abbr_l=`gsl__get_header_field 2 "$gsl_header_abbr"`
|
gsl__get_header_fields "$gsl_marker_abbr"
|
||||||
gsl_post_line_nbr=`gsl__get_line "$gsl_header_abbr" "$gsl_post"`
|
gsl__check_header_fields "Post" "ABBR" "$gsl_log_act_abbr" || continue
|
||||||
|
|
||||||
if ! [[ "$gsl_post_abbr_s" ]] || \
|
# Check POST CONTENT
|
||||||
! [[ "$gsl_post_abbr_l" ]];then
|
[[ `gsl__get_content_line \
|
||||||
|
"$gsl_post_header_field_1" \
|
||||||
|
"$gsl_post"` ]] \
|
||||||
|
&& gsl_post_stat_abbr=$(( gsl_post_stat_abbr + 1 )) \
|
||||||
|
&& continue
|
||||||
|
|
||||||
|
# Missing CONTENT
|
||||||
gsl__logs_print \
|
gsl__logs_print \
|
||||||
"$gsl_log_e" \
|
"$gsl_log_e" \
|
||||||
"Post" \
|
"Post" \
|
||||||
"ABBR" \
|
"ABBR" \
|
||||||
"Line:$gsl_post_line_nbr > Content: $gsl_log_act_abbr" \
|
"Missing Content: $gsl_post_header_field_1" \
|
||||||
"${PWD}/$gsl_post"
|
"${PWD}/$gsl_post"
|
||||||
gsl_checker_err=true
|
gsl_checker_err=true
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [[ `gsl__get_content_line "$gsl_post_abbr_s" "$gsl_post"` ]];then
|
|
||||||
gsl__logs_print \
|
|
||||||
"$gsl_log_e" \
|
|
||||||
"Post" \
|
|
||||||
"ABBR" \
|
|
||||||
"Missing Content: $gsl_post_abbr_s" \
|
|
||||||
"${PWD}/$gsl_post"
|
|
||||||
gsl_checker_err=true
|
|
||||||
else
|
|
||||||
(( gsl_post_stat_abbr ++ ))
|
|
||||||
fi
|
|
||||||
done < <(gsl__get_header "$gsl_marker_abbr" "$gsl_post")
|
done < <(gsl__get_header "$gsl_marker_abbr" "$gsl_post")
|
||||||
|
|
||||||
gsl__logs_print \
|
gsl__logs_print \
|
||||||
|
@ -364,55 +352,43 @@ gsl__logs_print \
|
||||||
# Check Post for LINKs HEADER + Content
|
# Check Post for LINKs HEADER + Content
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
gsl__post_check_links() {
|
gsl__post_check_links() {
|
||||||
while read -r "gsl_header_link"
|
gsl_post_stat_link=0
|
||||||
|
while read -r "gsl_header_content_line"
|
||||||
do
|
do
|
||||||
# Get in HEADERS
|
# Get & Check Header CONTENT
|
||||||
gsl_post_link_ref=`gsl__get_header_field 1 "$gsl_header_link"`
|
gsl__get_header_fields "$gsl_marker_link"
|
||||||
gsl_post_link_url=`gsl__get_header_field 2 "$gsl_header_link"`
|
gsl__check_header_fields "Post" "Link" "$gsl_log_act_link" || continue
|
||||||
gsl_post_link_alt=`gsl__get_header_field 3 "$gsl_header_link"`
|
|
||||||
gsl_post_line_nbr=`gsl__get_line "$gsl_marker_link$gsl_post_link_ref" "$gsl_post"`
|
|
||||||
|
|
||||||
if ! [[ "$gsl_post_link_ref" ]] || \
|
|
||||||
! [[ "$gsl_post_link_url" ]];then
|
|
||||||
|
|
||||||
gsl__logs_print \
|
|
||||||
"$gsl_log_e" \
|
|
||||||
"Post" \
|
|
||||||
"Link" \
|
|
||||||
"Line:$gsl_post_line_nbr > Content: $gsl_log_act_link" \
|
|
||||||
"${PWD}/$gsl_post"
|
|
||||||
gsl_checker_err=true
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Not ALT TEXT ?
|
# Not ALT TEXT ?
|
||||||
if ! [[ "$gsl_post_link_alt" ]];then
|
if ! [[ "$gsl_post_header_field_3" ]];then
|
||||||
gsl__logs_print \
|
gsl__logs_print \
|
||||||
"$gsl_log_w" \
|
"$gsl_log_w" \
|
||||||
"Post" \
|
"Post" \
|
||||||
"Link" \
|
"Link" \
|
||||||
"Line:$gsl_post_line_nbr > No ALT TEXT ?" \
|
"Line:$gsl_post_header_line_nbr > No ALT TEXT ?" \
|
||||||
"${PWD}/$gsl_post"
|
"${PWD}/$gsl_post"
|
||||||
gsl_checker_war=true
|
gsl_checker_war=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find if ref is in CONTENT
|
# Find if ref is in CONTENT
|
||||||
gsl_content_link=`
|
if [[ `gsl__get_content_finder \
|
||||||
gsl__get_content_finder \
|
|
||||||
-o "$gsl_mo_link" \
|
-o "$gsl_mo_link" \
|
||||||
-b "$gsl_post_link_ref" \
|
-b "$gsl_post_header_field_1" \
|
||||||
-c "$gsl_mc_link" \
|
-c "$gsl_mc_link" \
|
||||||
-f "$gsl_post" \
|
-f "$gsl_post" \
|
||||||
| tail -1`
|
| tail -1 ` ]];then
|
||||||
|
(( gsl_post_stat_link ++ ))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
if ! [[ $gsl_content_link ]];then
|
# Missing CONTENT
|
||||||
gsl__logs_print \
|
gsl__logs_print \
|
||||||
"$gsl_log_e" \
|
"$gsl_log_e" \
|
||||||
"Post" \
|
"Post" \
|
||||||
"Link" \
|
"Link" \
|
||||||
"Missing Content: [_${gsl_post_link_ref}_]" \
|
"Missing Content: [_${gsl_post_header_field_1}_]" \
|
||||||
"${PWD}/$gsl_post"
|
"${PWD}/$gsl_post"
|
||||||
gsl_checker_err=true
|
gsl_checker_err=true
|
||||||
fi
|
|
||||||
done < <(gsl__get_header "$gsl_marker_link" "$gsl_post")
|
done < <(gsl__get_header "$gsl_marker_link" "$gsl_post")
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ fi
|
||||||
|
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# TOOLS
|
# TOOLS. Getting line, markers, fields in headers...
|
||||||
#
|
#
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
@ -135,7 +135,7 @@ awk -F" : " -v f="$1" \
|
||||||
gsl__get_content_line() {
|
gsl__get_content_line() {
|
||||||
awk -v line="$gsl_post_begin" -v s="$1" \
|
awk -v line="$gsl_post_begin" -v s="$1" \
|
||||||
'NR >= line && $0 ~ s {print NR}' \
|
'NR >= line && $0 ~ s {print NR}' \
|
||||||
"$2"
|
"$2" || return
|
||||||
}
|
}
|
||||||
|
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
@ -161,8 +161,40 @@ done
|
||||||
! [[ "$mk_b" ]] && mk_b='.*'
|
! [[ "$mk_b" ]] && mk_b='.*'
|
||||||
|
|
||||||
if [[ "$file" ]];then
|
if [[ "$file" ]];then
|
||||||
grep -oP$line "(?<=$mk_o)$mk_b?(?=$mk_c)" "$file"
|
grep -oP$line "(?<=$mk_o)$mk_b?(?=$mk_c)" "$file" && return
|
||||||
elif [[ "$ivar" ]];then
|
elif [[ "$ivar" ]];then
|
||||||
grep -oP$line "(?<=$mk_o)$mk_b?(?=$mk_c)" <<< "$ivar"
|
grep -oP$line "(?<=$mk_o)$mk_b?(?=$mk_c)" <<< "$ivar" && return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#=======================================================================
|
||||||
|
# Get Fields and line nbr from header from marker
|
||||||
|
#=======================================================================
|
||||||
|
gsl__get_header_fields() {
|
||||||
|
gsl_post_header_field_1=`
|
||||||
|
gsl__get_header_field 1 "$gsl_header_content_line"`
|
||||||
|
gsl_post_header_field_2=`
|
||||||
|
gsl__get_header_field 2 "$gsl_header_content_line"`
|
||||||
|
gsl_post_header_field_3=`
|
||||||
|
gsl__get_header_field 3 "$gsl_header_content_line"`
|
||||||
|
gsl_post_header_line_nbr=`
|
||||||
|
gsl__get_line "$1$gsl_post_header_field_1" "$gsl_post"`
|
||||||
|
}
|
||||||
|
|
||||||
|
#=======================================================================
|
||||||
|
# Get Fields and line nbr from header from marker
|
||||||
|
#=======================================================================
|
||||||
|
gsl__check_header_fields() {
|
||||||
|
if ! [[ "$gsl_post_header_field_1" ]] || \
|
||||||
|
! [[ "$gsl_post_header_field_2" ]];then
|
||||||
|
|
||||||
|
gsl__logs_print \
|
||||||
|
"$gsl_log_e" \
|
||||||
|
"$1" \
|
||||||
|
"$2" \
|
||||||
|
"Line:$gsl_post_header_line_nbr > Content: $3" \
|
||||||
|
"${PWD}/$gsl_post"
|
||||||
|
gsl_checker_err=true
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue