OSDN Git Service

[fix] : Fixed SC2068
authorhayao <hayao@fascode.net>
Sat, 22 May 2021 12:29:29 +0000 (21:29 +0900)
committerhayao <hayao@fascode.net>
Sat, 22 May 2021 12:29:29 +0000 (21:29 +0900)
14 files changed:
channels/i3/airootfs.any/etc/skel/.config/rofi/power.sh
modules/lightdm/airootfs.any/root/customize_airootfs_lightdm.sh
system/pkgbuild.sh
tools/allpkglist.sh
tools/alteriso-info.sh
tools/channel.sh
tools/clean.sh
tools/kernel-choice-conf-gen.sh
tools/kernel.sh
tools/keyring.sh
tools/locale.sh
tools/pkglist.sh
tools/testpkg.sh
tools/wizard.sh

index e6b249c..76fdb36 100755 (executable)
@@ -22,7 +22,7 @@ declare -A menu_list=(
 
 function main() {
   local -r IFS=$'\n'
-  [[ $# -ne 0 ]] && eval "${menu_list[$1]}" || echo "${!menu_list[*]}"
+  [[ "${#}" -ne 0 ]] && eval "${menu_list[$1]}" || echo "${!menu_list[*]}"
 }
 
-main $@
+main "${@}"
index 20f2581..ee6e9c4 100755 (executable)
@@ -34,7 +34,7 @@ if [[ -f "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" ]] && cat "/etc
     else
         echo "Failed to set the session.Multiple sessions were found." >&2
         echo "Please set the session of automatic login in /etc/lightdm/lightdm.conf.d/02-autologin-session.conf"
-        echo "Found session: $(printf "%s " ${session_list[@]})"
+        echo "Found session: $(printf "%s " "${session_list[@]}")"
         sleep 0.5
         exit 1
     fi
index 662ec5c..4a2cd33 100755 (executable)
@@ -66,7 +66,7 @@ function user_check () {
 
 # 一般ユーザーで実行します
 function run_user () {
-    sudo -u "${build_username}" ${@}
+    sudo -u "${build_username}" "${@}"
 }
 
 # 引数を確認
@@ -106,12 +106,12 @@ pacman -Syy "${pacman_args[@]}"
 cd "${pkgbuild_dir}"
 pkgbuild_dirs=($(ls "${pkgbuild_dir}" 2> /dev/null))
 if (( "${#pkgbuild_dirs[@]}" != 0 )); then
-    for _dir in ${pkgbuild_dirs[@]}; do
+    for _dir in "${pkgbuild_dirs[@]}"; do
         cd "${_dir}"
         depends=($(source "${pkgbuild_dir}/${_dir}/PKGBUILD"; echo "${depends[@]}"))
         makedepends=($(source "${pkgbuild_dir}/${_dir}/PKGBUILD"; echo "${makedepends[@]}"))
         if (( ${#depends[@]} + ${#makedepends[@]} != 0 )); then
-            for _pkg in ${depends[@]} ${makedepends[@]}; do
+            for _pkg in "${depends[@]}" "${makedepends[@]}"; do
                 if pacman -Ssq "${_pkg}" | grep -x "${_pkg}" 1> /dev/null; then
                     pacman -S --asdeps --needed "${pacman_args[@]}" "${_pkg}"
                 fi
index c58fe05..4a3140d 100755 (executable)
@@ -79,7 +79,7 @@ fi
 
 load_config() {
     local _file
-    for _file in ${@}; do
+    for _file in "${@}"; do
         if [[ -f "${_file}" ]]; then
             source "${_file}"
         fi
@@ -89,7 +89,7 @@ load_config() {
 for_module(){
     local module
     for module in ${modules[@]}; do
-        eval $(echo ${@} | sed "s|{}|${module}|g")
+        eval $(echo "${@}" | sed "s|{}|${module}|g")
     done
 }
 
@@ -105,7 +105,7 @@ for arch in ${archs[@]}; do
                     modules=("share")
                 fi
             fi
-            for module in ${modules[@]}; do
+            for module in "${modules[@]}"; do
                 dependent="${module_dir}/${module}/dependent"
                 if [[ -f "${dependent}" ]]; then
                     modules+=($(grep -h -v ^'#' "${dependent}" | tr -d "\n" ))
index 6b0c327..9b5ed06 100755 (executable)
@@ -97,7 +97,7 @@ variable_list=(
     "iso_version"
 )
 
-for var in ${variable_list[@]}; do
+for var in "${variable_list[@]}"; do
     if [[ -z "$(eval echo '$'${var})" ]]; then
         echo "${var} is empty" >&2
         exit 1
index b4e8168..43ad180 100755 (executable)
@@ -237,10 +237,10 @@ else
 fi
 
 case "${mode}" in
-    "check" ) check ${@}                  ;;
+    "check" ) check "${@}"                ;;
     "show"  ) show                        ;;
-    "desc"  ) desc ${@}                   ;;
-    "ver"   ) get_alteriso_version ${@}   ;;
+    "desc"  ) desc "${@}"                 ;;
+    "ver"   ) get_alteriso_version "${@}" ;;
     "help"  ) _help; exit 0               ;;
     *       ) _help; exit 1               ;;
 esac
index f3ccf6a..c8a901c 100755 (executable)
@@ -14,7 +14,7 @@ noconfirm=false
 # load_config [file1] [file2] ...
 load_config() {
     local _file
-    for _file in ${@}; do
+    for _file in "${@}"; do
         if [[ -f "${_file}" ]]; then
             source "${_file}"
         fi
index 3214742..9aedee6 100755 (executable)
@@ -6,25 +6,9 @@ arch_list=(
     "i686"
 )
 
-# rm helper
-# Delete the file if it exists.
-# For directories, rm -rf is used.
-# If the file does not exist, skip it.
-# remove <file> <file> ...
-remove() {
-    local _list=($(echo "$@")) _file
-    for _file in "${_list[@]}"; do
-        if [[ -f "${_file}" ]]; then    
-            rm -f "${_file}"
-        elif [[ -d "${_file}" ]]; then
-            rm -rf "${_file}"
-        fi
-    done
-}
-
 #cd "${script_path}"
-for arch in ${arch_list[@]}; do
-    remove "${script_path}/menuconfig-script/kernel_choice_${arch}"
+for arch in "${arch_list[@]}"; do
+    rm -rf "${script_path}/menuconfig-script/kernel_choice_${arch}"
     for kernel in $(bash "${script_path}/tools/kernel.sh" -a "${arch}" show ); do
         echo "config KERNEL_N_A_M_E_${kernel}" >> "${script_path}/menuconfig-script/kernel_choice_${arch}"
         echo -e "\tbool ${kernel}" >> "${script_path}/menuconfig-script/kernel_choice_${arch}"
index 077cb41..a8029fd 100755 (executable)
@@ -101,7 +101,7 @@ get() {
     _kernel_name_list=($(cat "${_kernel_config_file}" | grep -h -v ^'#' | getclm 1))
     _get_kernel_line() {
         local _kernel _count=0
-        for _kernel in ${_kernel_name_list[@]}; do
+        for _kernel in "${_kernel_name_list[@]}"; do
             _count=$(( _count + 1 ))
             if [[ "${_kernel}" = "${1}" ]]; then echo "${_count}"; return 0; fi
         done
@@ -175,9 +175,9 @@ else
 fi
 
 case "${mode}" in
-    "check" ) check ${@}    ;;
+    "check" ) check "${@}"  ;;
     "show"  ) show          ;;
-    "get"   ) get ${@}      ;;
+    "get"   ) get "${@}"    ;;
     "help"  ) _help; exit 0 ;;
     *       ) _help; exit 1 ;;
 esac
index 7fbbf3b..f95ee7c 100755 (executable)
@@ -171,7 +171,7 @@ checkpkg() {
 
 run() {
     msg_info "Running ${*}"
-    ${@}
+    eval "${@}"
 }
 
 
index b91cf1d..71ccca7 100755 (executable)
@@ -90,13 +90,13 @@ get() {
     _locale_name_list=($(cat "${_locale_config_file}" | grep -h -v ^'#' | awk '{print $1}'))
     _get_locale_line_number() {
         local _lang _count=0
-        for _lang in ${_locale_name_list[@]}; do
+        for _lang in "${_locale_name_list[@]}"; do
             _count=$(( _count + 1 ))
             if [[ "${_lang}" = "${1}" ]]; then echo "${_count}"; return 0; fi
         done
         echo -n "failed"
     }
-    _locale_line_number="$(_get_locale_line_number ${@})"
+    _locale_line_number="$(_get_locale_line_number "${@}")"
 
     # 不正なロケール名なら終了する
     if [[ "${_locale_line_number}" = "failed" ]]; then
@@ -131,7 +131,7 @@ eval set -- "${OPT}"
 unset OPTS OPTL
 
 while true; do
-    case ${1} in
+    case "${1}" in
         -a | --arch)
             arch="${2}"
             shift 2
@@ -165,9 +165,9 @@ else
 fi
 
 case "${mode}" in
-    "check" ) check ${@}    ;;
+    "check" ) check "${@}"    ;;
     "show"  ) show          ;;
-    "get"   ) get ${@}      ;;
+    "get"   ) get "${@}"      ;;
     "help"  ) _help; exit 0 ;;
     *       ) _help; exit 1 ;;
 esac
index 48373d5..81cf07d 100755 (executable)
@@ -44,8 +44,8 @@ _help() {
 # for_module <command>
 for_module(){
     local module
-    for module in ${modules[@]}; do
-        eval $(echo ${@} | sed "s|{}|${module}|g")
+    for module in "${modules[@]}"; do
+        eval $(echo "${@}" | sed "s|{}|${module}|g")
     done
 }
 
@@ -183,7 +183,7 @@ fi
 
 #-- Read package list --#
 # Read the file and remove comments starting with # and add it to the list of packages to install.
-for _file in ${_loadfilelist[@]}; do
+for _file in "${_loadfilelist[@]}"; do
     if [[ -f "${_file}" ]]; then
         msg_debug "Loaded package file ${_file}"
         _pkglist=( ${_pkglist[@]} "$(grep -h -v ^'#' ${_file})" )
@@ -197,7 +197,7 @@ done
 _excludefile=("${channel_dir}/packages.${arch}/exclude" "${channel_dir}/packages_aur.${arch}/exclude")
 for_module '_excludefile+=("${module_dir}/{}/packages.${arch}/exclude" "${module_dir}/{}/packages_aur.${arch}/exclude")'
 
-for _file in ${_excludefile[@]}; do
+for _file in "${_excludefile[@]}"; do
     if [[ -f "${_file}" ]]; then
         _excludelist+=($(grep -h -v ^'#' "${_file}") )
     fi
index c88d2fc..88c5036 100755 (executable)
@@ -89,7 +89,7 @@ done
 
 # パッケージ一覧
 msg_debug "Getting package list ..."
-for arch in ${archs[@]}; do
+for arch in "${archs[@]}"; do
     packages+=($("${script_path}/tools/allpkglist.sh" -s -a "${arch}"))
 done
 
@@ -98,7 +98,7 @@ msg_debug "Getting group list ..."
 group_list=($(curl -s https://archlinux.org/groups/ | grep "/groups/x86_64" | cut -d "/" -f 4))
 
 # 実行開始
-for pkg in ${packages[@]}; do
+for pkg in "${packages[@]}"; do
     msg_debug "Searching ${pkg} ..."
     if ! searchpkg "${pkg}"; then
         echo "${pkg} is not in the official repository." >&2
index 13277ba..df8ebd2 100755 (executable)
@@ -166,7 +166,7 @@ Function_Global_Main_check_required_files () {
         "default.conf"
     )
 
-    for Var_Local_file in ${Var_Local_file_list[@]}; do
+    for Var_Local_file in "${Var_Local_file_list[@]}"; do
         if [[ ! -f "${Var_Global_Wizard_Env_script_path}/${Var_Local_file}" ]]; then
             msg_error "${Var_Local_file}が見つかりませんでした。" "${Var_Local_file} was not found."
             Var_Local_error=true
@@ -199,9 +199,9 @@ Function_Global_Main_install_dependent_packages () {
         local Var_Local_package Var_Local_installed_package Var_Local_installed_version
         Var_Local_installed_package=($(pacman -Q | getclm 1))
         Var_Local_installed_version=($(pacman -Q | getclm 2))
-        for Var_Local_package in $(seq 0 $(( ${#Var_Local_installed_package[@]} - 1 ))); do
-            if [[ ${Var_Local_installed_package[${Var_Local_package}]} = ${1} ]]; then
-                if [[ ${Var_Local_installed_version[${Var_Local_package}]} = $(pacman -Sp --print-format '%v' --config "${Var_Global_Wizard_Env_pacman_conf}" ${1}) ]]; then
+        for Var_Local_package in $(seq 0 $(( "${#Var_Local_installed_package[@]}" - 1 ))); do
+            if [[ "${Var_Local_installed_package[${Var_Local_package}]}" = "${1}" ]]; then
+                if [[ "${Var_Local_installed_version[${Var_Local_package}]}" = $(pacman -Sp --print-format '%v' --config "${Var_Global_Wizard_Env_pacman_conf}" ${1}) ]]; then
                     echo -n "true"
                     return 0
                 else
@@ -214,7 +214,7 @@ Function_Global_Main_install_dependent_packages () {
         return 0
     }
     echo
-    for Var_Local_package in ${dependence[@]}; do
+    for Var_Local_package in "${dependence[@]}"; do
         msg "依存パッケージ ${Var_Local_package} を確認しています..." "Checking dependency package ${Var_Local_package} ..."
         if [[ $(Function_Local_checkpkg ${Var_Local_package}) = false ]]; then
             Var_Global_missing_packages+=(${Var_Local_package})
@@ -255,7 +255,7 @@ Function_Global_Main_run_keyring.sh () {
 
 Function_Global_Main_remove_dependent_packages () {
     if [[ -n "${Var_Global_missing_packages[*]}" ]]; then
-        sudo pacman -Rsn --config "${Var_Global_Wizard_Env_pacman_conf}" ${Var_Global_missing_packages[@]}
+        sudo pacman -Rsn --config "${Var_Global_Wizard_Env_pacman_conf}" "${Var_Global_missing_packages[@]}"
     fi
 }
 
@@ -313,7 +313,7 @@ Function_Global_Ask_locale() {
 
     local Var_Local_locale_list Var_Local_locale Var_Local_count=1 Var_Local_input_locale
     Var_Local_locale_list=($("${Var_Global_Wizard_Env_script_path}/tools/locale.sh" -a "${Var_Global_Wizard_Option_build_arch}" show))
-    for Var_Local_locale in ${Var_Local_locale_list[@]}; do
+    for Var_Local_locale in "${Var_Local_locale_list[@]}"; do
         (
             local locale_name locale_gen_name locale_version locale_time locale_fullname
             eval $("${Var_Global_Wizard_Env_script_path}/tools/locale.sh" -a "${Var_Global_Wizard_Option_build_arch}" get "${Var_Local_locale}" )
@@ -328,7 +328,7 @@ Function_Global_Ask_locale() {
 
     set +e
     expr "${Var_Local_input_locale}" + 1 >/dev/null 2>&1
-    if [[ ${?} -lt 2 ]]; then
+    if [[ "${?}" -lt 2 ]]; then
         set -e
         # 数字である
         Var_Local_input_locale=$(( Var_Local_input_locale - 1 ))
@@ -562,7 +562,7 @@ Function_Global_Ask_kernel () {
 
     #選択肢の生成
     local Var_Local_kernel Var_Local_count=1 Var_Local_int
-    for Var_Local_kernel in ${Var_Local_kernel_list[@]}; do
+    for Var_Local_kernel in "${Var_Local_kernel_list[@]}"; do
         (
             local kernel kernel_filename kernel_mkinitcpio_profile
             eval $("${Var_Global_Wizard_Env_script_path}/tools/kernel.sh" -a "${Var_Global_Wizard_Option_build_arch}" get "${Var_Local_kernel}" )
@@ -616,7 +616,7 @@ Function_Global_Ask_channel () {
 
     msg "チャンネルを以下の番号から選択してください。" "Select a channel from the numbers below."
     # 選択肢を生成
-    for Var_Local_channel in ${Var_Local_channel_list[@]}; do
+    for Var_Local_channel in "${Var_Local_channel_list[@]}"; do
         if [[ -f "${Var_Global_Wizard_Env_script_path}/channels/${Var_Local_channel_dir[$(( Var_Local_count - 1 ))]}/description.txt" ]]; then
             Var_Local_description=$(cat "${Var_Global_Wizard_Env_script_path}/channels/${Var_Local_channel_dir[$(( Var_Local_count - 1 ))]}/description.txt")
         else