Created
July 17, 2019 11:09
-
-
Save elundmark/5d3af1e8aa51f0ec8306c18a550f47a7 to your computer and use it in GitHub Desktop.
Print arguments on sepearate lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
f() { | |
local -a args=("${@}") valid_args=() | |
local -i i=0 len=${#args[@]} | |
for (( ; i < len; i++ )); do | |
if [[ "${args[i]}" != '' ]] ; then | |
valid_args+=("${args[i]}") | |
else | |
echo "Removed empty string [$((i+1))]" 1>&2 | |
fi | |
done | |
if (( ${#valid_args[@]} > 0 )) ; then | |
local IFS=$'\n' | |
echo "${valid_args[*]}" | |
fi | |
return $? | |
} | |
f "${@}" | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment