Question:
How do I make a function that has dash parameters in Bash?
Repl link:
greet() {
echo "Hello, $n!"
}
greet -n "Jack"
Question:
How do I make a function that has dash parameters in Bash?
Repl link:
greet() {
echo "Hello, $n!"
}
greet -n "Jack"
I just did a Phind search and it doesn’t seem to be possible
Phind did say something like this could work, though
greet() {
while [ $# -gt 0 ]; do
if [[ \$1 == *"--"* ]]; then
v="${1/--/}"
declare $v="\$2"
fi
shift
done
echo "Hello, $n!"
}
greet --n "Jack"