(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}")" for n in ${!vector[@]}; do
root_dir="$(realpath "${root_dir}")" echo $n
else if (($n % 2 == 0)); then
root_dir="$(dirname "${0}")/$(dirname "${BASH_SOURCE}")" unset vector[$n]
root_dir="$(realpath "${root_dir}")"
fi fi
done
tput smso echo "after : ${vector[@]}"
echo ${root_dir} echo "after_index : ${!vector[@]}"
tput rmso
echo "blargh"