Skip to content

Instantly share code, notes, and snippets.

@progrium
Last active August 29, 2015 14:01
Show Gist options
  • Save progrium/215e210851fbcff7d1b6 to your computer and use it in GitHub Desktop.
Save progrium/215e210851fbcff7d1b6 to your computer and use it in GitHub Desktop.
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