#!/usr/bin/env bash
# http://wiki.bash-hackers.org/syntax/arrays
# début gros startup
command -v readlink &> /dev/null
if [ "$?" -eq "0" ] ; then
#shellcheck disable=SC2155
export ROOT_PATH="$( cd "$( dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}" )" )" && pwd )"
else
#shellcheck disable=SC2155
export ROOT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
# on genere un petit script pour la demo
cat << EOF > app.php
<?php
echo "declare -A sentence
sentence[Begin]='Be liberal in what'
sentence[Middle]='you accept, and conservative'
sentence[End]='in what you send'
sentence['Very end']='this is the end'" ;
EOF
source <(php -f "${ROOT_PATH}/app.php")
for element in Begin Middle End "Very end"; do
printf "%s\n" "${sentence[$element]}"
done
Comments