fork download
  1. #!/usr/bin/env bash
  2.  
  3. set -o errexit -o errtrace -o nounset -o pipefail
  4.  
  5. filter_empty_parameters() {
  6. local -a aParameters=()
  7.  
  8. for sParameter in "$@";do
  9. if [[ "${sParameter}" != "" ]];then
  10. aParameters+=( "${sParameter}" )
  11. fi
  12. done
  13.  
  14. for sParameter in "${aParameters[@]}";do
  15. echo ": '${sParameter}'"
  16. done
  17. }
  18.  
  19. filter_empty_parameters 'a' '' 'b b' c ' ' d 'e ' '' ' f'
  20.  
Success #stdin #stdout 0s 4268KB
stdin
Standard input is empty
stdout
: 'a'
: 'b b'
: 'c'
: ' '
: 'd'
: 'e '
: ' f'