@@ -140,7 +140,9 @@ count_audio_files() {
140140read_conf_key () {
141141 local key=" $1 "
142142 local file=" $2 "
143- grep " ^${key} =" " $file " 2> /dev/null | head -1 | cut -d' =' -f2- | tr -d ' "'
143+ # '|| true' on grep: under 'set -o pipefail' a no-match (exit 1) would
144+ # otherwise propagate as the pipeline's exit status and abort the script.
145+ { grep " ^${key} =" " $file " 2> /dev/null || true ; } | head -1 | cut -d' =' -f2- | tr -d ' "'
144146}
145147
146148# Return the predominant K3b-supported format (mp3/ogg/flac) found in MUSIC_REPO.
@@ -544,7 +546,7 @@ print_step "1/3" "Locating music repository"
544546# Note: EXISTING_MUSIC_REPO may already be pre-set from Audacious detection above;
545547# musiclib config takes priority if present, otherwise the Audacious-detected value is kept.
546548if [ -n " $EXISTING_CONFIG_FILE " ]; then
547- _conf_repo=$( grep ' ^ MUSIC_REPO= ' " $EXISTING_CONFIG_FILE " 2> /dev/null | head -1 | cut -d ' = ' -f2- | tr -d ' " ' )
549+ _conf_repo=$( read_conf_key MUSIC_REPO " $EXISTING_CONFIG_FILE " )
548550 _conf_repo=$( eval echo " $_conf_repo " 2> /dev/null || echo " $_conf_repo " )
549551 [ -n " $_conf_repo " ] && EXISTING_MUSIC_REPO=" $_conf_repo "
550552fi
@@ -607,7 +609,7 @@ print_step "2/3" "Configuring download directory"
607609# Read existing setting
608610EXISTING_DOWNLOAD_DIR=" "
609611if [ -n " $EXISTING_CONFIG_FILE " ]; then
610- EXISTING_DOWNLOAD_DIR=$( grep ' ^ NEW_DOWNLOAD_DIR= ' " $EXISTING_CONFIG_FILE " 2> /dev/null | head -1 | cut -d ' = ' -f2- | tr -d ' " ' )
612+ EXISTING_DOWNLOAD_DIR=$( read_conf_key NEW_DOWNLOAD_DIR " $EXISTING_CONFIG_FILE " )
611613 EXISTING_DOWNLOAD_DIR=$( eval echo " $EXISTING_DOWNLOAD_DIR " 2> /dev/null || echo " $EXISTING_DOWNLOAD_DIR " )
612614fi
613615
@@ -657,7 +659,7 @@ DEVICE_ID=""
657659# Read existing setting
658660EXISTING_DEVICE_ID=" "
659661if [ -n " $EXISTING_CONFIG_FILE " ]; then
660- EXISTING_DEVICE_ID=$( grep ' ^ DEVICE_ID= ' " $EXISTING_CONFIG_FILE " 2> /dev/null | head -1 | cut -d ' = ' -f2- | tr -d ' " ' )
662+ EXISTING_DEVICE_ID=$( read_conf_key DEVICE_ID " $EXISTING_CONFIG_FILE " )
661663fi
662664
663665if command -v kdeconnect-cli & > /dev/null; then
@@ -822,20 +824,17 @@ EOF
822824 # This runs once at install time; runtime drift is caught by sync_external_tool_config()
823825 # in musiclib_utils_tag_functions.sh on each subsequent script invocation.
824826 if command -v kid3-cli & > /dev/null; then
825- # Read POPM_STAR values from system config; fall back to kid3 defaults
827+ # Read POPM_STAR values from system config; fall back to kid3 defaults.
828+ # Uses read_conf_key() (pipeline starts with 'head -1' so it never
829+ # triggers set -o pipefail when the key is absent).
826830 _sys_conf=" /usr/lib/musiclib/config/musiclib.conf"
827831 _p1=1; _p2=64; _p3=128; _p4=196; _p5=255
828832 if [ -f " $_sys_conf " ]; then
829- _v=$( grep -E ' ^POPM_STAR1=' " $_sys_conf " | cut -d= -f2 | tr -d ' "' 2> /dev/null)
830- [ -n " $_v " ] && _p1=$_v
831- _v=$( grep -E ' ^POPM_STAR2=' " $_sys_conf " | cut -d= -f2 | tr -d ' "' 2> /dev/null)
832- [ -n " $_v " ] && _p2=$_v
833- _v=$( grep -E ' ^POPM_STAR3=' " $_sys_conf " | cut -d= -f2 | tr -d ' "' 2> /dev/null)
834- [ -n " $_v " ] && _p3=$_v
835- _v=$( grep -E ' ^POPM_STAR4=' " $_sys_conf " | cut -d= -f2 | tr -d ' "' 2> /dev/null)
836- [ -n " $_v " ] && _p4=$_v
837- _v=$( grep -E ' ^POPM_STAR5=' " $_sys_conf " | cut -d= -f2 | tr -d ' "' 2> /dev/null)
838- [ -n " $_v " ] && _p5=$_v
833+ _v=$( read_conf_key POPM_STAR1 " $_sys_conf " ) ; [ -n " $_v " ] && _p1=$_v || true
834+ _v=$( read_conf_key POPM_STAR2 " $_sys_conf " ) ; [ -n " $_v " ] && _p2=$_v || true
835+ _v=$( read_conf_key POPM_STAR3 " $_sys_conf " ) ; [ -n " $_v " ] && _p3=$_v || true
836+ _v=$( read_conf_key POPM_STAR4 " $_sys_conf " ) ; [ -n " $_v " ] && _p4=$_v || true
837+ _v=$( read_conf_key POPM_STAR5 " $_sys_conf " ) ; [ -n " $_v " ] && _p5=$_v || true
839838 fi
840839 # Point kid3-cli at the shared GUI config file (same as KID3_CONFIG_FILE in musiclib.conf)
841840 export KID3_CONFIG_FILE=" $HOME /.config/kid3rc"
@@ -1039,13 +1038,13 @@ DB_FILE="${DATA_DIR}/data/musiclib.dsv"
10391038if [ -f " $DB_FILE " ]; then
10401039 print_success " Database found"
10411040else
1042- echo " Looks like this is a first time install - no database found at: $MUSIC_REPO "
1041+ echo " Looks like this is a first time install - no database found at: $DB_FILE "
10431042 echo " "
10441043
10451044 if prompt_yn " Build it now?" " n" ; then
10461045 echo " "
10471046 if command -v musiclib-cli & > /dev/null; then
1048- musiclib-cli build || print_error " Database build failed"
1047+ musiclib-cli build " $MUSIC_REPO " || print_error " Database build failed"
10491048 else
10501049 print_error " musiclib-cli not found - install the musiclib package first"
10511050 print_info " When ready just run 'musiclib-cli build' in the terminal."
0 commit comments