Off-Topic > Off-Topic - Tiny Core Lounge

Why won't busybox ash shell execute this little script but bash does?

(1/1)

bigpcman:
I've hunted around for an answer to why the busybox ash shell won't execute this little script (actually just a function of a larger script) but the bash shell will. I wonder if there is a simple change that would make it acceptable for the ash shell. Anyway since there are so many experts on this forum I thought someone would know the answer. The error message is:

./test: line 3: syntax error: "(" unexpected


--- Code: ---#!/bin/sh

function testport() {
if netstat -an | egrep ":$1 .*LISTEN" > /dev/null
then
return 0
else
return 1
fi
}

--- End code ---

^thehatsrule^:
Just use myfunction()
Having 'function' is redundant anyways :)

(it's probably a 'bashism')

bigpcman:
Great! Thanks that fixed the problem.

Navigation

[0] Message Index

Go to full version