Advertisement
bunam

Untitled

Nov 7th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # http://wiki.bash-hackers.org/syntax/arrays
  4.  
  5. # début gros startup
  6. command -v readlink &> /dev/null
  7. if [ "$?" -eq "0" ] ; then
  8.     #shellcheck disable=SC2155
  9.     export ROOT_PATH="$( cd "$( dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}" )" )" && pwd )"
  10. else
  11.     #shellcheck disable=SC2155
  12.     export ROOT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  13. fi
  14.  
  15. # on genere un petit script pour la demo
  16. cat << EOF > app.php
  17. <?php
  18.  
  19. echo "declare -A sentence
  20.  
  21. sentence[Begin]='Be liberal in what'
  22. sentence[Middle]='you accept, and conservative'
  23. sentence[End]='in what you send'
  24. sentence['Very end']='this is the end'" ;
  25. EOF
  26.  
  27. source <(php -f "${ROOT_PATH}/app.php")
  28.  
  29. for element in Begin Middle End "Very end"; do
  30.    printf "%s\n" "${sentence[$element]}"
  31. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement