Skip to content

Commit

Permalink
feat: show errors beside the path to be removed in Clean-Log feature
Browse files Browse the repository at this point in the history
Show error beside the path due to which it is to be removed during cleaning of log file.
  • Loading branch information
CodesOfRishi committed Jan 17, 2022
1 parent a694be0 commit 4e83ed2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions feats/hist-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ __smartcd::clean_log() {
while [[ ${line_no} -le ${SMARTCD_HIST_DIR_LOG_SIZE} ]]; do
_path=$( sed -n ${line_no}'p' "${SMARTCD_HIST_DIR_LOG}" )

if [[ -d ${_path} ]]; then printf '%s\n' "${_path}" >> "${valid_paths}"
elif [[ -n ${_path} ]]; then printf '%s\n' "${_path}"; fi
if [[ -n ${_path} ]]; then
local _cd_error=$( builtin cd "${_path}" 2>&1 1> /dev/null )
if [[ -z ${_cd_error} ]]; then
printf '%s\n' "${_path}" >> "${valid_paths}"
else
printf '%s\n' "${_path} $( printf '%s\n' "${_cd_error}" | __smartcd::col_n 6 ":" )"
fi
fi
line_no=$(( line_no + 1 ))
done
printf '\n'
Expand Down

0 comments on commit 4e83ed2

Please sign in to comment.