many small fixes

This commit is contained in:
2025-09-13 18:03:04 -05:00
parent 748ccd4e3c
commit 814664adee
4 changed files with 79 additions and 46 deletions

View File

@@ -203,6 +203,30 @@ is_positive_integer() {
return 0
}
replace_line() {
local file="$1"
local search="$2"
local newLine="$3"
local newFile="${TMP_DIR}/$(bash_basename "${file}")"
test -f "${newFile}" && rm "${newFile}"
while read -r line; do
if line_contains "${line}" "${search}"; then
echo -en "${newLine}" >>"${newFile}"
continue
fi
echo "${line}" >>"${newFile}"
done <"${file}"
cp "${newFile}" "${file}"
}
remove_line() {
local file="$1"
local search="$2"
replace_line "${file}" "${search}" ''
}
bash_sort() {
local arr=("$@")
local n=${#arr[@]}