Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Is there a way to declare and pass parameters for shell functions, like so ?

function msg( m )
   read -p "Task #" + m + "done. Press any key to continue
share|improve this question

you didn't specify which shell, but assuming bash (or zsh):

function msg() {
     read -p "Task #${1} done. Press any key to continue"

and then you just use it like

% msg "foobar"

with $0 - $X you acces the nth parameter, in $* and $@ you find the whole line. just check the manual of your shell.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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