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
|
||||
|
||||
# Init log datas
|
||||
gsl_log_a=' ~ '
|
||||
gsl_log_e='Err'
|
||||
gsl_log_w='War'
|
||||
gsl_log_i='Inf'
|
||||
|
|
|
@ -90,7 +90,7 @@ case "$1" in
|
|||
;;
|
||||
|
||||
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." \
|
||||
&& exit
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ gsl__logs_print() {
|
|||
#4: Infos
|
||||
#5: File
|
||||
printf '%s %s\t%s\t%s\t%s\t%s\n' \
|
||||
"`date +%F' ~ '%T`" \
|
||||
"`date +%F' '%T`" \
|
||||
"$1" \
|
||||
"$2" \
|
||||
"$3" \
|
||||
|
@ -27,7 +27,6 @@ printf '%s %s\t%s\t%s\t%s\t%s\n' \
|
|||
# Show logs from file with filters
|
||||
#-----------------------------------------------------------------------
|
||||
gsl__logs_show() {
|
||||
clear
|
||||
|
||||
# Choices are important, but let's give priority
|
||||
[[ "$gsl_logs_inf" ]] \
|
||||
|
@ -41,12 +40,6 @@ clear
|
|||
&& gsl_log_show_session="Last session" \
|
||||
|| 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
|
||||
if [[ "$gsl_logs_last_session" ]];then
|
||||
gsl_log_start_line=`
|
||||
|
@ -54,8 +47,6 @@ if [[ "$gsl_logs_last_session" ]];then
|
|||
| tail -1 \
|
||||
| awk -F: '{print $1}'`
|
||||
|
||||
printf '%s\n \n' "$gsl_logs_infos"
|
||||
|
||||
awk -v sl="$gsl_log_start_line" \
|
||||
'NR >= sl' \
|
||||
"$gsl_file_logs" \
|
||||
|
@ -63,8 +54,6 @@ if [[ "$gsl_logs_last_session" ]];then
|
|||
| grep -Ei "$gsl_logs_search" \
|
||||
| column -t -s$'\t'
|
||||
else
|
||||
printf '%s\n' "$gsl_logs_infos"
|
||||
|
||||
while read -r "gsl_log_content"
|
||||
do
|
||||
# Let's read clear sessions
|
||||
|
|
|
@ -26,9 +26,7 @@ gsl__post_check_abbr
|
|||
echo -ne "\r\033[2K: Searching for 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
|
||||
[[ "$gsl_checker_war" ]] \
|
||||
&& gsl log -s -w
|
||||
|
@ -199,7 +197,6 @@ if (( "$gsl_post_p_open_nbr" == 0 ));then
|
|||
"Missing content: ( and ) at begining lines" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_err=true
|
||||
gsl_checker_err=true
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -320,36 +317,27 @@ fi
|
|||
#=======================================================================
|
||||
gsl__post_check_abbr() {
|
||||
gsl_post_stat_abbr=0
|
||||
while read -r "gsl_header_abbr"
|
||||
while read -r "gsl_header_content_line"
|
||||
do
|
||||
gsl_post_abbr_s=`gsl__get_header_field 1 "$gsl_header_abbr"`
|
||||
gsl_post_abbr_l=`gsl__get_header_field 2 "$gsl_header_abbr"`
|
||||
gsl_post_line_nbr=`gsl__get_line "$gsl_header_abbr" "$gsl_post"`
|
||||
# Get & Check HEADER CONTENT
|
||||
gsl__get_header_fields "$gsl_marker_abbr"
|
||||
gsl__check_header_fields "Post" "ABBR" "$gsl_log_act_abbr" || continue
|
||||
|
||||
if ! [[ "$gsl_post_abbr_s" ]] || \
|
||||
! [[ "$gsl_post_abbr_l" ]];then
|
||||
# Check POST CONTENT
|
||||
[[ `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_log_e" \
|
||||
"Post" \
|
||||
"ABBR" \
|
||||
"Line:$gsl_post_line_nbr > Content: $gsl_log_act_abbr" \
|
||||
"Missing Content: $gsl_post_header_field_1" \
|
||||
"${PWD}/$gsl_post"
|
||||
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")
|
||||
|
||||
gsl__logs_print \
|
||||
|
@ -364,55 +352,43 @@ gsl__logs_print \
|
|||
# Check Post for LINKs HEADER + Content
|
||||
#=======================================================================
|
||||
gsl__post_check_links() {
|
||||
while read -r "gsl_header_link"
|
||||
gsl_post_stat_link=0
|
||||
while read -r "gsl_header_content_line"
|
||||
do
|
||||
# Get in HEADERS
|
||||
gsl_post_link_ref=`gsl__get_header_field 1 "$gsl_header_link"`
|
||||
gsl_post_link_url=`gsl__get_header_field 2 "$gsl_header_link"`
|
||||
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
|
||||
# Get & Check Header CONTENT
|
||||
gsl__get_header_fields "$gsl_marker_link"
|
||||
gsl__check_header_fields "Post" "Link" "$gsl_log_act_link" || continue
|
||||
|
||||
# Not ALT TEXT ?
|
||||
if ! [[ "$gsl_post_link_alt" ]];then
|
||||
if ! [[ "$gsl_post_header_field_3" ]];then
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Link" \
|
||||
"Line:$gsl_post_line_nbr > No ALT TEXT ?" \
|
||||
"Line:$gsl_post_header_line_nbr > No ALT TEXT ?" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_war=true
|
||||
fi
|
||||
|
||||
# Find if ref is in CONTENT
|
||||
gsl_content_link=`
|
||||
gsl__get_content_finder \
|
||||
if [[ `gsl__get_content_finder \
|
||||
-o "$gsl_mo_link" \
|
||||
-b "$gsl_post_link_ref" \
|
||||
-b "$gsl_post_header_field_1" \
|
||||
-c "$gsl_mc_link" \
|
||||
-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_log_e" \
|
||||
"Post" \
|
||||
"Link" \
|
||||
"Missing Content: [_${gsl_post_link_ref}_]" \
|
||||
"Missing Content: [_${gsl_post_header_field_1}_]" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_err=true
|
||||
fi
|
||||
|
||||
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() {
|
||||
awk -v line="$gsl_post_begin" -v s="$1" \
|
||||
'NR >= line && $0 ~ s {print NR}' \
|
||||
"$2"
|
||||
"$2" || return
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
|
@ -161,8 +161,40 @@ done
|
|||
! [[ "$mk_b" ]] && mk_b='.*'
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue