(bash) arrays are weird

This commit is contained in:
2026-02-19 23:46:57 +01:00
parent 7477a1dc37
commit 118fcef730
+10 -14
View File
@@ -1,19 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# NOTE: this is way simpler vector=({1..20})
echo $(realpath "${BASH_SOURCE}")
# NOTE: this is useless echo "before : ${vector[@]}"
if [[ "${0}" == "${BASH_SOURCE}" ]]; then
root_dir="$(dirname "${0}")"
root_dir="$(realpath "${root_dir}")"
else
root_dir="$(dirname "${0}")/$(dirname "${BASH_SOURCE}")"
root_dir="$(realpath "${root_dir}")"
fi
tput smso for n in ${!vector[@]}; do
echo ${root_dir} echo $n
tput rmso if (($n % 2 == 0)); then
unset vector[$n]
fi
done
echo "blargh" echo "after : ${vector[@]}"
echo "after_index : ${!vector[@]}"