LDP/LDP/guide/docbook/abs-guide/func-cmdlinearg.sh

25 lines
525 B
Bash
Raw Permalink Normal View History

2005-02-09 20:54:20 +00:00
#!/bin/bash
# func-cmdlinearg.sh
# Call this script with a command-line argument,
#+ something like $0 arg1.
func ()
{
2012-04-04 22:51:18 +00:00
echo "$1" # Echoes first arg passed to the function.
} # Does a command-line arg qualify?
2005-02-09 20:54:20 +00:00
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