Skip to content

Commit cdd979b

Browse files
committed
[fix] : Fixed the detailed writing style
1 parent a78c077 commit cdd979b

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

build.sh

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,10 @@ DEFAULT_ARGUMENT=""
3030
alteriso_version="3.1"
3131

3232
# Load config file
33-
if [[ -f "${defaultconfig}" ]]; then
34-
source "${defaultconfig}"
35-
else
36-
"${tools_dir}/msg.sh" -a 'build.sh' error "${defaultconfig} was not found."
37-
exit 1
38-
fi
39-
40-
# Load custom.conf
41-
if [[ -f "${script_path}/custom.conf" ]]; then
42-
source "${script_path}/custom.conf"
43-
fi
33+
[[ ! -f "${defaultconfig}" ]] && "${tools_dir}/msg.sh" -a 'build.sh' error "${defaultconfig} was not found." && exit 1
34+
for config in "${defaultconfig}" "${script_path}/custom.conf"; do
35+
[[ -f "${script_path}/${config}.conf" ]] && source "${script_path}/${config}.conf"
36+
done
4437

4538
umask 0022
4639

@@ -365,11 +358,9 @@ prepare_env() {
365358
# 強制終了時に作業ディレクトリを削除する
366359
local _trap_remove_work
367360
_trap_remove_work() {
368-
local status=${?}
369-
if [[ "${normwork}" = false ]]; then
370-
echo; _run_cleansh
371-
fi
372-
exit ${status}
361+
local status="${?}"
362+
[[ "${normwork}" = false ]] && echo && _run_cleansh
363+
exit "${status}"
373364
}
374365
trap '_trap_remove_work' 1 2 3 15
375366

@@ -433,22 +424,16 @@ prepare_build() {
433424
local module_check
434425
module_check(){
435426
msg_debug "Checking ${1} module ..."
436-
if ! bash "${tools_dir}/module.sh" check "${1}"; then
437-
msg_error "Module ${1} is not available." "1";
438-
fi
427+
! bash "${tools_dir}/module.sh" check "${1}" && msg_error "Module ${1} is not available." "1";
439428
}
440429
modules=($(printf "%s\n" "${modules[@]}" | awk '!a[$0]++'))
441430
for_module "module_check {}"
442431
for_module load_config "${module_dir}/{}/config.any" "${module_dir}/{}/config.${arch}"
443432
msg_debug "Loaded modules: ${modules[*]}"
444-
if ! printf "%s\n" "${modules[@]}" | grep -x "share" >/dev/null 2>&1; then
445-
msg_warn "The share module is not loaded."
446-
fi
433+
! printf "%s\n" "${modules[@]}" | grep -x "share" >/dev/null 2>&1 && msg_warn "The share module is not loaded."
447434

448435
# Set kernel
449-
if [[ "${customized_kernel}" = false ]]; then
450-
kernel="${defaultkernel}"
451-
fi
436+
[[ "${customized_kernel}" = false ]] && kernel="${defaultkernel}"
452437

453438
# Parse files
454439
eval "$(bash "${tools_dir}/locale.sh" -s -a "${arch}" get "${locale_name}")"
@@ -482,9 +467,7 @@ prepare_build() {
482467

483468
# Run with tee
484469
if [[ ! "${logging}" = false ]]; then
485-
if [[ "${customized_logpath}" = false ]]; then
486-
logging="${out_dir}/${iso_filename%.iso}.log"
487-
fi
470+
[[ "${customized_logpath}" = false ]] && logging="${out_dir}/${iso_filename%.iso}.log"
488471
mkdir -p "$(dirname "${logging}")"; touch "${logging}"
489472
msg_warn "Re-run sudo ${0} ${ARGUMENT[*]} --nodepend --nolog --nocolor 2>&1 | tee ${logging}"
490473
sudo "${0}" "${ARGUMENT[@]}" --nolog --nocolor --nodepend 2>&1 | tee "${logging}"

0 commit comments

Comments
 (0)