bkctld-check-incs: Correct shellchek warnings

- SC2013: To read lines rather than words, pipe/redirect to a 'while
  read' loop.
- SC2086: Double quote to prevent globbing and word splitting.
This commit is contained in:
Brice Waegeneire 2021-02-08 11:38:56 +01:00 committed by Jérémy Lecour
parent c27cb81b57
commit 3215ab2fa3
2 changed files with 7 additions and 5 deletions

View file

@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
* bkctld-check-incs: Correct shellsheck warnings
### Deprecated
### Removed

View file

@ -7,7 +7,7 @@
set -u
# shellcheck source=./includes
LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes"
LIBDIR="$(dirname "$0")" && . "${LIBDIR}/includes"
# default return value is 0 (succes)
rc=0
@ -22,12 +22,12 @@ for jail_name in $("${LIBDIR}/bkctld-list"); do
if [ -n "${incs_policy_file}" ]; then
# get jail last configuration date
jail_config_epoch=$(date --date "$(stat -c %y ${incs_policy_file})" +"%s")
jail_config_epoch=$(date --date "$(stat -c %y "${incs_policy_file}")" +"%s")
# loop for each line in jail configuration
for line in $(cat ${incs_policy_file}); do
# read each line in jail configuration
while IFS= read -r line < "${incs_policy_file}"; do
# inc date in ISO format
inc_iso=$(relative_date ${line})
inc_iso=$(relative_date "${line}")
# inc date in seconds from epoch
inc_epoch=$(date --date "${inc_iso}" +"%s")