Skip to main content
Question Protected by dr_
edited title
Link
Volker Siegel
  • 17.8k
  • 6
  • 56
  • 81

difference between function"function foo() {}" and foo"foo() {}"

Tweeted twitter.com/#!/StackUnix/status/327756133009874945
Source Link

difference between function foo() {} and foo() {}

I can define bash functions using or omitting the function keyword. Is there any difference?

#!/bin/bash

function foo() {
  echo "foo"
}

bar() {
  echo "bar"
}

foo

bar

Both calls to functions foo and bar succeed and I can't see any difference. So I am wondering if it is just to improve readability, or there is something that I am missing...

BTW in other shells like dash (/bin/sh is symlinked to dash in debian/ubuntu) it fails when using the function keyword.