diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index db5fdbc79..d09f9eb93 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -12,7 +12,7 @@ fn_alert_log(){ info_config.sh info_messages.sh if [ -f "${alertlog}" ]; then - rm "${alertlog}" + rm -f "${alertlog:?}" fi { diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index c1da544e2..46953e1b3 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -17,12 +17,12 @@ fn_backup_trap(){ echo -en "backup ${backupname}.tar.gz..." fn_print_canceled_eol_nl fn_script_log_info "Backup ${backupname}.tar.gz: CANCELED" - rm -f "${backupdir}/${backupname}.tar.gz" | tee -a "${lgsmlog}" + rm -f "${backupdir:?}/${backupname}.tar.gz" | tee -a "${lgsmlog}" echo -en "backup ${backupname}.tar.gz..." fn_print_removed_eol_nl fn_script_log_info "Backup ${backupname}.tar.gz: REMOVED" # Remove lock file. - rm -f "${tmpdir}/.backup.lock" + rm -f "${tmpdir:?}/.backup.lock" core_exit.sh } @@ -153,7 +153,7 @@ fn_backup_compression(){ fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fi # Remove lock file - rm -f "${tmpdir}/.backup.lock" + rm -f "${tmpdir:?}/.backup.lock" } # Clear old backups according to maxbackups and maxbackupdays variables. diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index e50965882..d80f5e766 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -11,7 +11,7 @@ local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") # Trap to remove lockfile on quit. fn_lockfile_trap(){ # Remove lockfile. - rm -f "${rootdir}/${lockselfname}" + rm -f "${rootdir:?}/${lockselfname}" # resets terminal. Servers can sometimes mess up the terminal on exit. reset fn_print_ok_nl "Closing debug" diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index 61f40c808..ba80921c6 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -9,7 +9,7 @@ local commandaction="Dev-Debug" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") if [ -f "${rootdir}/.dev-debug" ]; then - rm "${rootdir}/.dev-debug" + rm "${rootdir:?}/.dev-debug" fn_print_ok_nl "Disabled dev-debug" fn_script_log_info "Disabled dev-debug" else diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index 83476a7bb..b308c3579 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -207,21 +207,21 @@ echo -e "Required Librarys" echo -e "=================================" sort "${tmpdir}/.depdetect_readelf" | uniq echo -en "\n" -rm -f "${tmpdir}/.depdetect_centos_line" -rm -f "${tmpdir}/.depdetect_centos_list" -rm -f "${tmpdir}/.depdetect_centos_list_uniq" - -rm -f "${tmpdir}/.depdetect_debian_line" -rm -f "${tmpdir}/.depdetect_debian_list" -rm -f "${tmpdir}/.depdetect_debian_list_uniq" - -rm -f "${tmpdir}/.depdetect_ubuntu_line" -rm -f "${tmpdir}/.depdetect_ubuntu_list" -rm -f "${tmpdir}/.depdetect_ubuntu_list_uniq" - -rm -f "${tmpdir}/.depdetect_readelf" -rm -f "${tmpdir}/.depdetect_readelf_uniq" -rm -f "${tmpdir}/.depdetect_unknown" -rm -f "${tmpdir}/.depdetect_unknown_uniq" +rm -f "${tmpdir:?}/.depdetect_centos_line" +rm -f "${tmpdir:?}/.depdetect_centos_list" +rm -f "${tmpdir:?}/.depdetect_centos_list_uniq" + +rm -f "${tmpdir:?}/.depdetect_debian_line" +rm -f "${tmpdir:?}/.depdetect_debian_list" +rm -f "${tmpdir:?}/.depdetect_debian_list_uniq" + +rm -f "${tmpdir:?}/.depdetect_ubuntu_line" +rm -f "${tmpdir:?}/.depdetect_ubuntu_list" +rm -f "${tmpdir:?}/.depdetect_ubuntu_list_uniq" + +rm -f "${tmpdir:?}/.depdetect_readelf" +rm -f "${tmpdir:?}/.depdetect_readelf_uniq" +rm -f "${tmpdir:?}/.depdetect_unknown" +rm -f "${tmpdir:?}/.depdetect_unknown_uniq" core_exit.sh diff --git a/lgsm/functions/command_dev_detect_glibc.sh b/lgsm/functions/command_dev_detect_glibc.sh index a8b463e2c..add6a05b6 100644 --- a/lgsm/functions/command_dev_detect_glibc.sh +++ b/lgsm/functions/command_dev_detect_glibc.sh @@ -70,8 +70,8 @@ do echo -e "" echo -e "All required GLIBC versions" cat "${tmpdir}/detect_glibc_${glibc_check_var}.tmp" | sort | uniq | sort -r --version-sort - rm "${tmpdir}/detect_glibc_${glibc_check_var}.tmp" - rm "${tmpdir}/detect_glibc_files_${glibc_check_var}.tmp" + rm -f "${tmpdir:?}/detect_glibc_${glibc_check_var}.tmp" + rm -f "${tmpdir:?}/detect_glibc_files_${glibc_check_var}.tmp" else fn_print_information_nl "glibc is not required" fi @@ -84,7 +84,7 @@ echo -e "Final glibc Requirement" echo -e "=================================" if [ -f "${tmpdir}/detect_glibc_highest.tmp" ]; then cat "${tmpdir}/detect_glibc_highest.tmp" | sort | uniq | sort -r --version-sort | head -1 - rm "${tmpdir}/detect_glibc_highest.tmp" + rm -f "${tmpdir:?}/detect_glibc_highest.tmp" else fn_print_information_nl "glibc is not required" fi diff --git a/lgsm/functions/command_dev_detect_ldd.sh b/lgsm/functions/command_dev_detect_ldd.sh index 7f360fe84..f612366bf 100644 --- a/lgsm/functions/command_dev_detect_ldd.sh +++ b/lgsm/functions/command_dev_detect_ldd.sh @@ -55,7 +55,7 @@ echo -e "Not Found" echo -e "=================================" cat "${tmpdir}/detect_ldd_not_found.tmp" -rm "${tmpdir}/detect_ldd.tmp" -rm "${tmpdir}/detect_ldd_not_found.tmp" +rm -f "${tmpdir:?}/detect_ldd.tmp" +rm -f "${tmpdir:?}/detect_ldd_not_found.tmp" core_exit.sh diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 54ae7fe94..d6600a7af 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -67,7 +67,7 @@ fn_clear_old_fastdl(){ # Clearing old FastDL. if [ -d "${fastdldir}" ]; then echo -en "clearing existing FastDL directory ${fastdldir}..." - rm -R "${fastdldir:?}" + rm -fR "${fastdldir:?}" exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl @@ -147,7 +147,7 @@ fn_human_readable_file_size(){ fn_fastdl_preview(){ # Remove any file list. if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then - rm -f "${tmpdir}/fastdl_files_to_compress.txt" + rm -f "${tmpdir:?}/fastdl_files_to_compress.txt" fi echo -e "analysing required files" fn_script_log_info "Analysing required files" @@ -228,7 +228,7 @@ fn_fastdl_preview(){ fi echo -e "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)" fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)" - rm "${tmpdir}/fastdl_files_to_compress.txt" + rm -f "${tmpdir:?}/fastdl_files_to_compress.txt" if ! fn_prompt_yn "Continue?" Y; then fn_script_log "User exited" core_exit.sh @@ -276,7 +276,7 @@ fn_fastdl_gmod(){ # Clear addons directory in fastdl. echo -en "clearing addons dir from fastdl dir..." fn_sleep_time - rm -R "${fastdldir:?}/addons" + rm -fR "${fastdldir:?}/addons" exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl @@ -379,7 +379,7 @@ fn_fastdl_gmod_dl_enforcer(){ # Clear old lua file. if [ -f "${luafastdlfullpath}" ]; then echo -en "removing existing download enforcer: ${luafastdlfile}..." - rm "${luafastdlfullpath:?}" + rm -f "${luafastdlfullpath:?}" exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl diff --git a/lgsm/functions/command_mods_remove.sh b/lgsm/functions/command_mods_remove.sh index 0c869b88b..cec994fea 100644 --- a/lgsm/functions/command_mods_remove.sh +++ b/lgsm/functions/command_mods_remove.sh @@ -68,7 +68,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do # If file or directory exists, then remove it. if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then - rm -rf "${modinstalldir:?}/${currentfileremove}" + rm -rf "${modinstalldir:?}/${currentfileremove:?}" ((exitcode=$?)) if [ ${exitcode} -ne 0 ]; then fn_script_log_fatal "Removing ${modinstalldir}/${currentfileremove}" @@ -91,7 +91,7 @@ fn_sleep_time # Remove file list. echo -en "removing ${modcommand}-files.txt..." fn_sleep_time -rm -rf "${modsdir}/${modcommand}-files.txt" +rm -rf "${modsdir:?}/${modcommand}-files.txt" local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_script_log_fatal "Removing ${modsdir}/${modcommand}-files.txt" diff --git a/lgsm/functions/command_postdetails.sh b/lgsm/functions/command_postdetails.sh index 7e5d14355..6bbca3d0a 100644 --- a/lgsm/functions/command_postdetails.sh +++ b/lgsm/functions/command_postdetails.sh @@ -44,7 +44,7 @@ fn_bad_postdetailslog() { # Remove any existing postdetails.log file. if [ -f "${postdetailslog}" ]; then - rm -f "${postdetailslog}" + rm -f "${postdetailslog:?}" fi # Rather than a one-pass sed parser, default to using a temporary directory. diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 80ffdd19a..5d440c60c 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -159,7 +159,7 @@ fn_sleep_time fn_print_ok "${servername}" fn_script_log_pass "Started ${servername}" fi - rm "${lgsmlogdir}/.${selfname}-tmux-error.tmp" + rm "${lgsmlogdir:?}/.${selfname}-tmux-error.tmp" echo -en "\n" } diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 609425595..471be97a5 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -242,7 +242,7 @@ info_config.sh fn_stop_pre_check # Remove lockfile. if [ -f "${rootdir}/${lockselfname}" ]; then - rm -f "${rootdir}/${lockselfname}" + rm -f "${rootdir:?}/${lockselfname}" fi if [ -z "${exitbypass}" ]; then diff --git a/lgsm/functions/command_update_linuxgsm.sh b/lgsm/functions/command_update_linuxgsm.sh index c2529f43c..f337ce342 100644 --- a/lgsm/functions/command_update_linuxgsm.sh +++ b/lgsm/functions/command_update_linuxgsm.sh @@ -20,7 +20,7 @@ if [ -z "${legacymode}" ]; then if [ "${config_file_diff}" != "" ]; then fn_print_update_eol_nl fn_script_log_info "checking config _default.cfg: UPDATE" - rm -f "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" + rm -f "${configdirdefault:?}/config-lgsm/${gameservername}/_default.cfg" fn_fetch_config "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "_default.cfg" "nochmodx" "norun" "noforce" "nomd5" alert="config" alert.sh @@ -34,7 +34,7 @@ if [ -z "${legacymode}" ]; then if [ "${tmp_script_diff}" != "" ]; then fn_print_update_eol_nl fn_script_log_info "checking linuxgsm.sh: UPDATE" - rm -f "${tmpdir}/linuxgsm.sh" + rm -f "${tmpdir:?}/linuxgsm.sh" fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "nochmodx" "norun" "noforcedl" "nomd5" # Compare selfname against linuxgsm.sh in the tmp dir. Ignoring server specific vars. else @@ -87,7 +87,7 @@ if [ -n "${functionsdir}" ]; then fn_print_fail_eol_nl echo -en " removing unknown function ${functionfile}...\c" fn_script_log_fatal "removing unknown function ${functionfile}" - if ! rm -f "${functionfile}"; then + if ! rm -f "${functionfile:?}"; then fn_print_fail_eol_nl core_exit.sh else diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh index 3940e8066..bc7a9ffb8 100644 --- a/lgsm/functions/compress_unreal2_maps.sh +++ b/lgsm/functions/compress_unreal2_maps.sh @@ -21,7 +21,7 @@ if ! fn_prompt_yn "Start compression?" Y; then return fi mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 -rm -rfv "${serverfiles}/Maps/"*.ut2.uz2 +rm -rfv "${serverfiles:?}/Maps/"*.ut2.uz2 cd "${systemdir}" || exit for map in "${serverfiles}/Maps/"*; do ./ucc-bin compress "${map}" --nohomedir diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index 100740acb..9f24ff9a3 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -21,7 +21,7 @@ if ! fn_prompt_yn "Start compression?" Y; then return fi mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 -rm -rfv "${serverfiles}/Maps/"*.unr.uz +rm -rfv "${serverfiles:?}/Maps/"*.unr.uz cd "${systemdir}" || exit for map in "${serverfiles}/Maps/"*; do ./ucc-bin compress "${map}" --nohomedir diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 3874c8f24..9a59d5ab8 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -105,7 +105,7 @@ fn_fetch_trap(){ fn_print_canceled_eol_nl fn_script_log_info "Downloading ${local_filename}...CANCELED" fn_sleep_time - rm -f "${local_filedir}/${local_filename}" + rm -f "${local_filedir:?}/${local_filename}" echo -en "downloading ${local_filename}..." fn_print_removed_eol_nl fn_script_log_info "Downloading ${local_filename}...REMOVED" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index f0ce44d7c..2b985569e 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -94,7 +94,7 @@ fn_install_server_files_steamcmd(){ find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf fi if [ "${counter}" -ge "9" ]; then - rm -rf "${steamcmddir}" + rm -rf "${steamcmddir:?}" check_steamcmd.sh fi diff --git a/lgsm/functions/mods_core.sh b/lgsm/functions/mods_core.sh index 083b91818..42c19d08d 100644 --- a/lgsm/functions/mods_core.sh +++ b/lgsm/functions/mods_core.sh @@ -440,7 +440,7 @@ fn_mods_create_tmp_dir(){ fn_mods_clear_tmp_dir(){ if [ -d "${modstmpdir}" ]; then echo -en "clearing mod download directory ${modstmpdir}..." - rm -r "${modstmpdir}" + rm -fr "${modstmpdir:?}" exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl @@ -454,7 +454,7 @@ fn_mods_clear_tmp_dir(){ fi # Clear temp file list as well. if [ -f "${modsdir}/.removedfiles.tmp" ]; then - rm "${modsdir}/.removedfiles.tmp" + rm -f "${modsdir:?}/.removedfiles.tmp" fi } diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index c55237c2b..b1f3b99b2 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -156,7 +156,7 @@ fn_appmanifest_check(){ fn_script_log_error "Multiple appmanifest_${appid}.acf files found" fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" for appfile in ${appmanifestfile}; do - rm "${appfile}" + rm -f "${appfile:?}" done appmanifestfilewc1="${appmanifestfilewc}" fn_appmanifest_info diff --git a/tests/tests_defaultcfg/tests_defaultcfg.sh b/tests/tests_defaultcfg/tests_defaultcfg.sh index 5e139fb4d..5b9b47f2a 100644 --- a/tests/tests_defaultcfg/tests_defaultcfg.sh +++ b/tests/tests_defaultcfg/tests_defaultcfg.sh @@ -16,7 +16,7 @@ while IFS= read -r -d $'\0' line; do echo "${diffoutput}" echo "" fi - rm defaultcfgtemp.txt + rm -f defaultcfgtemp.txt done echo -e "" @@ -36,7 +36,7 @@ while IFS= read -r -d $'\0' line; do echo "${diffoutput}" echo "" fi - rm defaultcfgtemp.txt + rm -f defaultcfgtemp.txt done echo -e "" @@ -56,5 +56,5 @@ while IFS= read -r -d $'\0' line; do echo "${diffoutput}" echo "" fi - rm defaultcfgtemp.txt + rm -f defaultcfgtemp.txt done diff --git a/tests/tests_fctrserver.sh b/tests/tests_fctrserver.sh index 6561c7ff4..14c111d55 100644 --- a/tests/tests_fctrserver.sh +++ b/tests/tests_fctrserver.sh @@ -1013,6 +1013,6 @@ requiredstatus="OFFLINE" fn_setstatus if [ ! -v TRAVIS ]; then fn_print_info "Tidying up directories." - rm -rfv "${serverfiles}" + rm -rfv "${serverfiles:?}" fi core_exit.sh diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 9478fa638..6887b2d45 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -829,7 +829,7 @@ echo -e "Command: ./jc2server update" requiredstatus="OFFLINE" fn_setstatus fn_print_info_nl "removed appmanifest_${appid}.acf." -rm --verbose "${serverfiles}/steamapps/appmanifest_${appid}.acf" +rm --verbose "${serverfiles:?}/steamapps/appmanifest_${appid}.acf" ( exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log" BASH_XTRACEFD="5" @@ -1174,6 +1174,6 @@ requiredstatus="OFFLINE" fn_setstatus if [ ! -v TRAVIS ]; then fn_print_info "Tidying up directories." - rm -rfv "${serverfiles}" + rm -rfv "${serverfiles:?}" fi core_exit.sh diff --git a/tests/tests_mcserver.sh b/tests/tests_mcserver.sh index 8224c5e8c..4d6378d97 100644 --- a/tests/tests_mcserver.sh +++ b/tests/tests_mcserver.sh @@ -1060,6 +1060,6 @@ requiredstatus="OFFLINE" fn_setstatus if [ ! -v TRAVIS ]; then fn_print_info "Tidying up directories." - rm -rfv "${serverfiles}" + rm -rfv "${serverfiles:?}" fi core_exit.sh diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index 831b1f207..cd56c456d 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -1013,6 +1013,6 @@ requiredstatus="OFFLINE" fn_setstatus if [ ! -v TRAVIS ]; then fn_print_info "Tidying up directories." - rm -rfv "${serverfiles}" + rm -rfv "${serverfiles:?}" fi core_exit.sh