Skip to content
This repository was archived by the owner on Mar 5, 2019. It is now read-only.

Commit 8e0243a

Browse files
datedfaustbrian
authored andcommitted
fix: check if logfile exists before tailing (#68)
1 parent e979a96 commit 8e0243a

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

actions/log.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,30 @@
33
utils_log ()
44
{
55
clear
6-
echo -e "\n$(text_yellow " Use Ctrl+C to return to menu")\n"
7-
trap : INT
86

9-
local log_file=$(ls -t "${CORE_DATA}/logs/core/${CORE_NETWORK}/" | head -n 1)
10-
tail -fn 50 "${CORE_DATA}/logs/core/${CORE_NETWORK}/${log_file}"
7+
local log_dir="${CORE_DATA}/logs/core/${CORE_NETWORK}/"
8+
9+
if [[ ! -d "$log_dir" ]]; then
10+
ascii
11+
12+
error "Log folder does not exist."
13+
14+
return 1
15+
fi
16+
17+
local log_file=$(ls -t "${log_dir}" | head -n 1)
18+
19+
if [[ ! -e "${log_dir}/${log_file}" ]]; then
20+
ascii
21+
22+
error "Log file does not exist."
23+
24+
return 1
25+
else
26+
echo -e "\n$(text_yellow " Use Ctrl+C to return to menu")\n"
27+
28+
trap : INT
29+
30+
tail -fn 50 "${log_dir}/${log_file}"
31+
fi
1132
}

menus/main/args.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ menu_main_parse_args ()
3838
l|L)
3939
utils_log
4040

41-
press_to_continue
41+
if [[ $? -eq 130 ]]; then
42+
press_to_continue
43+
else
44+
wait_to_continue
45+
fi
4246
;;
4347
h|H)
4448
menu_main_help

0 commit comments

Comments
 (0)