argumentos de función bash
Function shell variables
All function parameters or arguments can be accessed via $1, $2, $3,..., $N.
$0 always point to the shell script name.
$* or $@ holds all parameters or arguments passed to the function.
$# holds the number of positional parameters passed to the function.
How do I display function name?
$0 always point to the shell script name. However, you can use an array variable called FUNCNAME which contains the names of all shell functions currently in the execution call stack. The element with index 0 is the name any currently-executing shell function.This variable exists only when a shell function is executing.
FUNCNAME in action
Create a shell script called funcback.sh:
#!/bin/bash
# funcback.sh : Use $FUNCNAME
backup(){
local d="$1"
[[ -z $d ]] && { echo "${FUNCNAME}(): directory name not specified"; exit 1; }
echo "Starting backup..."
}
backup $1
DreamCoder