Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
destructuring_assignment_for_named_local_args() {
declare numbers letters words
read numbers letters words <<<"$@"
echo "$numbers"
echo "$letters"
echo "$words"
}
destructuring_assignment_for_named_local_args 123 abc "Hello world"
# Actually, for local args, this is still probably preferrable:
declare_named_local_args() {
declare numbers="$1" letters="$2" words="$3"
echo "$numbers"
echo "$letters"
echo "$words"
}
declare_named_local_args 123 abc "Hello world"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment