@@ -58,44 +58,35 @@ msg_common(){
5858
5959# Show an INFO message
6060# ${1}: message string
61- msg_info () {
62- msg_common info " ${@ } "
63- }
61+ msg_info () { msg_common info " ${@ } " ; }
6462
6563# Show an Warning message
6664# ${1}: message string
67- msg_warn () {
68- msg_common warn " ${@ } "
69- }
65+ msg_warn () { msg_common warn " ${@ } " ; }
7066
7167# Show an debug message
7268# ${1}: message string
73- msg_debug () {
74- if [[ " ${debug} " = true ]]; then
75- msg_common debug " ${@ } "
76- fi
69+ msg_debug () {
70+ [[ " ${debug} " = true ]] && msg_common debug " ${@ } "
71+ return 0
7772}
7873
7974# Show an ERROR message then exit with status
8075# ${1}: message string
8176# ${2}: exit code number (with 0 does not exit)
8277msg_error () {
8378 msg_common error " ${1} "
84- if [[ -n " ${2:- } " ]]; then
85- exit " ${2} "
86- fi
79+ [[ -n " ${2:- } " ]] && exit " ${2} "
8780}
8881
8982
9083# Usage: getclm <number>
9184# 標準入力から値を受けとり、引数で指定された列を抽出します。
92- getclm () { cat - | cut -d " " -f " ${1} " ; }
85+ getclm () { cut -d " " -f " ${1} " ; }
9386
9487# Usage: echo_blank <number>
9588# 指定されたぶんの半角空白文字を出力します
96- echo_blank (){
97- yes " " 2> /dev/null | head -n " ${1} " | tr -d " \n"
98- }
89+ echo_blank (){ yes " " 2> /dev/null | head -n " ${1} " | tr -d " \n" ; }
9990
10091_usage () {
10192 echo " usage ${0} [options] [channel]"
@@ -178,7 +169,7 @@ _usage () {
178169_umount () { if mountpoint -q " ${1} " ; then umount -lf " ${1} " ; fi ; }
179170
180171# Mount helper Usage: _mount <source> <target>
181- _mount () { if ! mountpoint -q " ${2} " && [[ -f " ${1} " ]] && [[ -d " ${2} " ]]; then mount " ${1} " " ${2} " ; fi ; }
172+ _mount () { ! mountpoint -q " ${2} " && [[ -f " ${1} " ]] && [[ -d " ${2} " ]] && mount " ${1} " " ${2} " ; }
182173
183174# Unmount work dir
184175umount_work () {
@@ -187,7 +178,6 @@ umount_work () {
187178 msg_error " Exception error about working directory" 1
188179 fi
189180 [[ ! -d " ${build_dir} " ]] && return 0
190- # for _mount in $(cat "/proc/mounts" | getclm 2 | grep "$(realpath -s ${build_dir})" | tac | grep -xv "$(realpath -s ${airootfs_dir})"); do
191181 for _mount in $( find " ${build_dir} " -mindepth 1 -type d -printf " %p\0" | xargs -0 -I{} bash -c " mountpoint -q {} && echo {}" | tac) ; do
192182 if echo " ${_mount} " | grep " ${work_dir} " > /dev/null 2>&1 || echo " ${_mount} " | grep " ${script_path} " > /dev/null 2>&1 || echo " ${_mount} " | grep " ${out_dir} " > /dev/null 2>&1 ; then
193183 msg_info " Unmounting ${_mount} "
@@ -238,7 +228,8 @@ umount_trap() {
238228# load_config [file1] [file2] ...
239229load_config () {
240230 local _file
241- for _file in " ${@ } " ; do if [[ -f " ${_file} " ]] ; then source " ${_file} " && msg_debug " The settings have been overwritten by the ${_file} " ; fi ; done
231+ for _file in " ${@ } " ; do [[ -f " ${_file} " ]] && source " ${_file} " && msg_debug " The settings have been overwritten by the ${_file} " ; done
232+ return 0
242233}
243234
244235# Display channel list
@@ -272,7 +263,7 @@ _pacstrap(){
272263# /etc/alteriso-pacman.confを準備してコマンドを実行します
273264_run_with_pacmanconf (){
274265 sed " s|^CacheDir =|#CacheDir =|g" " ${build_dir} /pacman.conf" > " ${airootfs_dir} /etc/alteriso-pacman.conf"
275- " ${@ } "
266+ eval -- " ${@ } "
276267 remove " ${airootfs_dir} /etc/alteriso-pacman.conf"
277268}
278269
@@ -333,9 +324,9 @@ check_bool() {
333324 eval ' : ${' ${_variable} ' :=""}'
334325 _value=" $( eval echo ' $' ${_variable} ) "
335326 if [[ ! -v " ${1} " ]] || [[ " ${_value} " = " " ]]; then
336- if [[ " ${debug} " = true ]]; then echo ; fi ; msg_error " The variable name ${_variable} is empty." " 1"
327+ [[ " ${debug} " = true ]] && echo ; msg_error " The variable name ${_variable} is empty." " 1"
337328 elif [[ ! " ${_value} " = " true" ]] && [[ ! " ${_value} " = " false" ]]; then
338- if [[ " ${debug} " = true ]]; then echo ; fi ; msg_error " The variable name ${_variable} is not of bool type. " " 1"
329+ [[ " ${debug} " = true ]] && echo ; msg_error " The variable name ${_variable} is not of bool type ( ${_variable} = ${_value} ) " " 1"
339330 elif [[ " ${debug} " = true ]]; then
340331 echo -e " ${_value} "
341332 fi
0 commit comments