Skip to content

Instantly share code, notes, and snippets.

@scribu
Last active December 17, 2015 19:19
Show Gist options
  • Save scribu/5660088 to your computer and use it in GitHub Desktop.
Save scribu/5660088 to your computer and use it in GitHub Desktop.
bash arg handling inside functions
#!/usr/bin/env bash
function fn_star() {
for word in "$*"; do
echo $word
done
}
function fn_at() {
for word in "$@"; do
echo $word
done
}
echo "fn_star:"
fn_star 1 '2 3'
echo "fn_at:"
fn_at 1 '2 3'
@scribu
Copy link
Author

scribu commented May 28, 2013

Output:

fn_star:
1 2 3
fn_at:
1
2 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment