• R/O
  • HTTP
  • SSH
  • HTTPS

crshini: Commit

GitHubのミラーです
https://github.com/hayao0819/crshini


Commit MetaInfo

Révisioned5dc9683b6285312110fd90d63d437b3106b4b3 (tree)
l'heure2021-06-08 21:30:26
Auteurhayao <hayao@fasc...>
Commiterhayao

Message de Log

[update] : Supports multiple parameters

Change Summary

Modification

--- a/src/libcrshini
+++ b/src/libcrshini
@@ -233,10 +233,10 @@ _crshini_merge(){
233233
234234
235235 # --del command
236-# _crshini_del file section [param] [list value]
236+# _crshini_del file section [list param]
237237 _crshini_del(){
238238 # Set variables
239- local _crshini_del_fileline=() _crshini_del_output=() __line _crshini_del_insection=false _crshini_del_file _crshini_del_section _crshini_del_param
239+ local _crshini_del_fileline=() _crshini_del_output=() __line _crshini_del_insection=false _crshini_del_file _crshini_del_section _crshini_del_param _crshini_del_lineout
240240 if [[ "${_crshini_stdin}" = true ]]; then
241241 readarray -t _crshini_del_fileline
242242 else
@@ -246,9 +246,11 @@ _crshini_del(){
246246 readarray -t _crshini_del_fileline < "${_crshini_del_file}"
247247 fi
248248
249- _crshini_del_section="${1}" _crshini_del_param="${2-""}"
249+ _crshini_del_section="${1}" && shift 1
250+ _crshini_del_param=("${@}")
250251
251252 for __line in $(seq "${#_crshini_del_fileline[@]}"); do
253+ _crshini_del_lineout=true
252254 case "${_crshini_del_fileline[$(( __line - 1 ))]}" in
253255 "[${_crshini_del_section}]")
254256 _crshini_del_insection=true
@@ -258,10 +260,24 @@ _crshini_del(){
258260 _crshini_del_insection=false
259261 ;;
260262 esac
261- if [[ "${_crshini_del_insection}" = true ]] && { [[ -z "${_crshini_del_param}" ]] || [[ "${_crshini_del_fileline[$(( __line - 1 ))]%%=*}" = "${_crshini_del_param}" ]]; }; then
262- _crshini_msg_dbg "${__line}行目を削除しました"
263+
264+ if [[ "${_crshini_del_insection}" = false ]]; then
265+ _crshini_del_lineout=true # 出力する
266+ elif [[ -z "${_crshini_del_param}" ]]; then #あとで配列版に書き直す
267+ _crshini_del_lineout=false # セクション内にいて、パラメータが設定されていないので出力しない
263268 else
269+ for __param in "${_crshini_del_param[@]}"; do
270+ if [[ "${_crshini_del_fileline[$(( __line - 1 ))]%%=*}" = "${__param}" ]]; then
271+ _crshini_del_lineout=false # パラメータの削除一覧に該当したので出力しない
272+ break
273+ fi
274+ done
275+ fi
276+
277+ if [[ "${_crshini_del_lineout}" = true ]]; then # _crshini_del_lineoutがtrueなら出力する、falseなら出力しない
264278 _crshini_del_output+=("${_crshini_del_fileline[$(( __line - 1 ))]}")
279+ else
280+ _crshini_msg_dbg "${__line}行目を削除しました"
265281 fi
266282 done
267283
Afficher sur ancien navigateur de dépôt.