@@ -197,14 +197,15 @@ fn_mod_get_info() {
197197 # Variable to know when job is done.
198198 modinfocommand=" 0"
199199 # Find entry in global array.
200- for (( index = 0 ; index <= ${# mods_global_array[@]} ; index++ )) ; do
200+ for (( index = 0 ; index < ${# mods_global_array[@]} ; index++ )) ; do
201201 # When entry is found.
202202 if [ " ${mods_global_array[index]} " == " ${currentmod} " ]; then
203203 # Go back to the previous "MOD" separator.
204- for (( index = index; index <= ${ # mods_global_array[@]} ; index -- )) ; do
204+ for (( index_search = index; index_search >= 0 ; index_search -- )) ; do
205205 # When "MOD" is found.
206- if [ " ${mods_global_array[index ]} " == " MOD" ]; then
206+ if [ " ${mods_global_array[index_search ]} " == " MOD" ]; then
207207 # Get info.
208+ index=${index_search}
208209 fn_mods_define
209210 modinfocommand=" 1"
210211 break
@@ -331,7 +332,7 @@ fn_compatible_mod_engines() {
331332 # How many engines we need to test.
332333 enginesamount=$( echo -e " ${modengines} " | awk -F ' ;' ' { print NF }' )
333334 # Test all subvalue of "modengines" using the ";" separator.
334- for (( gamevarindex = 1 ; gamevarindex < ${ enginesamount} ; gamevarindex++ )) ; do
335+ for (( gamevarindex = 1 ; gamevarindex < enginesamount; gamevarindex++ )) ; do
335336 # Put current engine name into modtest variable.
336337 enginemodtest=$( echo -e " ${modengines} " | awk -F ' ;' -v x=${gamevarindex} ' { print $x }' )
337338 # If engine name matches.
@@ -472,7 +473,7 @@ fn_mods_check_installed() {
472473 # Count installed mods.
473474 fn_mods_count_installed
474475 # If no mods are found.
475- if [ ${installedmodscount} -eq 0 ]; then
476+ if [ " ${installedmodscount} " -eq 0 ]; then
476477 echo -e " "
477478 fn_print_failure_nl " No installed mods or addons were found"
478479 echo -e " * Install mods using LinuxGSM first with: ./${selfname} mods-install"
@@ -689,13 +690,9 @@ fn_mod_install_amxmodx_file() {
689690 # since it does exist, is the entry already in plugins.ini
690691 logentry=" line (linux addons/amxmodx/dlls/amxmodx_mm_i386.so) inserted into ${modinstalldir} /addons/metamod/plugins.ini"
691692 echo -en " adding amxmodx_mm_i386.so in plugins.ini..."
692- grep -q " amxmodx_mm_i386.so" " ${modinstalldir} /addons/metamod/plugins.ini"
693- exitcode=$?
694- if [ " ${exitcode} " -ne 0 ]; then
693+ if ! grep -q " amxmodx_mm_i386.so" " ${modinstalldir} /addons/metamod/plugins.ini" ; then
695694 # file exists but the entry does not, let's add it
696- echo " linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> " ${modinstalldir} /addons/metamod/plugins.ini"
697- exitcode=$?
698- if [ " ${exitcode} " -ne 0 ]; then
695+ if ! echo " linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> " ${modinstalldir} /addons/metamod/plugins.ini" ; then
699696 fn_script_log_fail " ${logentry} "
700697 fn_print_fail_eol_nl
701698 else
@@ -705,9 +702,7 @@ fn_mod_install_amxmodx_file() {
705702 fi
706703 else
707704 # create new file and add the mod to it
708- echo " linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > " ${modinstalldir} /addons/metamod/plugins.ini"
709- exitcode=$?
710- if [ " ${exitcode} " -ne 0 ]; then
705+ if ! echo " linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > " ${modinstalldir} /addons/metamod/plugins.ini" ; then
711706 fn_script_log_fail " ${logentry} "
712707 fn_print_fail_eol_nl
713708 core_exit.sh
@@ -723,10 +718,8 @@ fn_mod_remove_amxmodx_file() {
723718 # since it does exist, is the entry already in plugins.ini
724719 logentry=" line (linux addons/amxmodx/dlls/amxmodx_mm_i386.so) removed from ${modinstalldir} /addons/metamod/plugins.ini"
725720 echo -en " removing amxmodx_mm_i386.so in plugins.ini..."
726- grep -q " linux addons/amxmodx/dlls/amxmodx_mm_i386.so" " ${modinstalldir} /addons/metamod/plugins.ini"
727- # iIs it found? If so remove it and clean up
728- exitcode=$?
729- if [ " ${exitcode} " -eq 0 ]; then
721+ # is it found? If so remove it and clean up
722+ if grep -q " linux addons/amxmodx/dlls/amxmodx_mm_i386.so" " ${modinstalldir} /addons/metamod/plugins.ini" ; then
730723 # delete the line we inserted
731724 sed -i ' /linux addons\/amxmodx\/dlls\/amxmodx_mm_i386.so/d' " ${modinstalldir} /addons/metamod/plugins.ini"
732725 # remove empty lines
0 commit comments