mirror of https://github.com/tLDP/LDP
25 lines
525 B
Bash
25 lines
525 B
Bash
#!/bin/bash
|
|
# func-cmdlinearg.sh
|
|
# Call this script with a command-line argument,
|
|
#+ something like $0 arg1.
|
|
|
|
|
|
func ()
|
|
|
|
{
|
|
echo "$1" # Echoes first arg passed to the function.
|
|
} # Does a command-line arg qualify?
|
|
|
|
echo "First call to function: no arg passed."
|
|
echo "See if command-line arg is seen."
|
|
func
|
|
# No! Command-line arg not seen.
|
|
|
|
echo "============================================================"
|
|
echo
|
|
echo "Second call to function: command-line arg passed explicitly."
|
|
func $1
|
|
# Now it's seen!
|
|
|
|
exit 0
|