Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what's the meaning of $@ for /bin/sh 1

Status
Not open for further replies.

stefanwagner

Programmer
Oct 19, 2003
2,373
DE
I found following line in a script, and don't know what it means:
Code:
exec "$FOO_EXEC_CMD" ${1+"$@"}
I guess it will expand to something like "first argument" and a simple echo-hack shows, to all arguments (tested with two).

Shell: /bin/sh
(really invoked: bash)

seeking a job as java-programmer in Berlin:
 
$1 is parameter 1
$2 is parameter 1
..

$@ is the complete string of the parameters, example:

ex.sh:

#/bin/bash
echo $1
echo $2
echo $@

# ./ex.sh a b
a
b
a b

Cheers.

Chacal, Inc.[wavey]
 
${1+"$@"}
If $1 is set then returns "$@" (ie "$1" "$2" ... "$$#") else returns nothing.

In your shell man page have a look to Parameters substitution.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top