Last active
August 3, 2019 15:20
-
-
Save travispaul/9688457044ab2473f15908b696cc9806 to your computer and use it in GitHub Desktop.
Setting a default value for $@ (sh vs dash vs ksh vs bash)
This file contains hidden or 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
#!/bin/sh | |
#!/bin/ksh | |
#!/usr/pkg/bin/dash | |
#!/usr/pkg/bin/bash | |
somefn() { | |
local args="${@:-something}" | |
echo "Value of \$args: $args" | |
} | |
# prints "something" | |
somefn | |
# prints "foo" in every shell but bash, where it prints "foo bar" | |
somefn foo bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment