I\'m trying to run a bash script on my Ubuntu machine and it is giving me an error:
function not found
To test, I
Doesn't it require () after function name, or at the call?
function sayIt() { ...
}
sayIt()
? :)
Hmm, actually, on MY mac, it works just as you pasted..
dtpwmbp:~ pwadas$ cat aa.sh
#!/bin/bash
function sayIt() {
echo "hello world"
}
sayIt
dtpwmbp:~ pwadas$ ./aa.sh
hello world
dtpwmbp:~ pwadas$
Compare bash version, AFAIR some older version required "()"s.
dtpwmbp:~ pwadas$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
dtpwmbp:~ pwadas$
Also compare state of shopt options ( man bash ), on both shells, maybe one of them have some compat syntax turned on or off ? "shopt" command without args will list state of options supported.
What is the 'function' keyword used in some bash scripts?