(bash) arrays are weird
This commit is contained in:
+10
-14
@@ -1,19 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: this is way simpler
|
||||
echo $(realpath "${BASH_SOURCE}")
|
||||
vector=({1..20})
|
||||
|
||||
# NOTE: this is useless
|
||||
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}")"
|
||||
echo "before : ${vector[@]}"
|
||||
|
||||
for n in ${!vector[@]}; do
|
||||
echo $n
|
||||
if (($n % 2 == 0)); then
|
||||
unset vector[$n]
|
||||
fi
|
||||
done
|
||||
|
||||
tput smso
|
||||
echo ${root_dir}
|
||||
tput rmso
|
||||
|
||||
echo "blargh"
|
||||
echo "after : ${vector[@]}"
|
||||
echo "after_index : ${!vector[@]}"
|
||||
|
||||
Reference in New Issue
Block a user