Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # package http://sekysu.blogspot.com
- #
- # Gera log que pode ser útil para debugar funções escritas em shell scripts
- # file tiny-function-exec-log.sh
- #
- # charset UTF-8
- # endofline Linux
- # since 2012-26-01 19:30 (GMT -03:00)
- # license GPL v2.0
- #
- # system GNU bash, version 3.1.17(2)-release i486 slackware 12.2
- # autor Paulo Riceli Dias Lelis [ http://sekysu.blogspot.com ]
- # more http://sekysu.blogspot.com
- #
- # Variáveis
- # Nome do arquivo que irá receber o log de execução das funções
- SF_DBGF='SFDBG'
- # Funções
- function _debugFunction()
- {
- # data e hora
- _DT=$(date +%Y-%m-%d_%H:%M:%S)
- # Arquivo de destino do log
- _FL="/tmp/${SF_DBG_FL}${_DT}.txt"
- # function name: ${FUNCNAME}
- # line number: ${BASH_LINENO}
- # params number: ${#@}
- # params: ${@}
- echo 'echo -e "'${_DT} : '${FUNCNAME} : ${BASH_LINENO} : ${#@} : ${@} : ${_MSGDBG[@]} " >> '${_FL}
- }
- #
- # Table test function
- function _tableTest()
- {
- unset _MSGDBG
- _MSGDBG[0]='start loop'
- for i in {1..3}
- do
- _MSGDBG[$i]='\n\t - in the loop $i = '"$i"
- echo -ne "$i"
- done
- echo
- A=${#_MSGDBG[@]}
- _MSGDBG[$A]="\nend of Loop"
- eval $( _debugFunction $@ )
- }
- # Testes de mesa
- # Diretamente
- _tableTest 3 'bar' 'foo' 'beer'
- # Linha de comando
- _tableTest ${@}
- # Boa sorte!!!
Advertisement
Add Comment
Please, Sign In to add comment