echo ${!argv[$arg]}
bad array subscript errorwhile(Size & 3)
declare -A argv
for i in $#; do
argv["$@[$i]"]=$i
done
'--output'.*|'-o'.*
)
if defined as --output=whatever
it would be --output=whatever
if defined as --output whatever
it would be --output
if [[ ${!argv[*]} =~ '--output'.*|'-o'.* ]]; then
arg="${BASH_REMATCH[1]}"
# -o=x
if [[ $arg == *'='* ]]; then # this line does not work
outpath="${arg#*=}"
# -o x
else
next=$(expr ${!argv["$arg"]} + 1)
outpath="${argv[$next]}"
fi
fi
argv["$@[$i]"]=$i
$@[1]=1
..
(edited)for((i=0;i<$#;i++)); do
$ bash -c 'echo "${@[0]}"'
bash: line 1: ${@[0]}: bad substitution
$@[${!i}]
elif [[ "$arg" =~ '--output'.*|'-o'.* ]]; then
if [[ "$arg" == *'='* ]]; then
output_directory="${1#*=}"
else
output_directory="${2}"
shift
fi
shift
ewan@machine ~/git-sparse-clone> git-sparse-clone https://github.com/DDNet/DDNet /README.md -o DDNet-Readme
Cloning into 'DDNet-Readme'...
...
ewan@machine ~/git-sparse-clone> cd DDNet-Readme/
ewan@machine ~/g/DDNet-Readme (master)> ls
README.md
(edited)[ "$(printf "foo")" = "foo" ]
is the same as [ "foo" = "foo" ]
if [ -z "$GIT" ]; then