Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I saw this in the end of an awesome shell script but I can't understand the login here because I think it's being short-handed for a longer command.

spark ${@:-`cat`}

This apears at the end of this script. Any ideas?

+ Marks for some one who extends it into a full segment of code, even if its slower (Better for explanation)

share|improve this question

marked as duplicate by Stephen Kitt, slm bash Jun 1 at 11:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 21 down vote accepted

It's the first special case of parameter substitution in man bash:

${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

In the case you mentioned, either the user has provided arguments on the command line and they will be used, or the user is asked to input them on standard input afterwards.

share|improve this answer

Afaik :- is basically: use $@ OR `cat` ( without setting $@ to `cat` )...

so some variable substition thingy...

Edit: So it gives you some sort of interactive input...

Here's a little Terminal test:

localhost:~ _druu$ echo ${@:-`cat`}
hello
world
;)
^\hello world ;)
localhost:~ _druu$ 
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.