Jump to content

runClient.sh bashism/linuxism


raj

Recommended Posts

On linux, sh and bash are the same, but on non-linux systems this is not true. The runClient.sh script uses pushd which is a bash feature, but the script is executed under sh. So when I run runClient.sh on my FreeBSD box, it of course doesn't work because FreeBSD has a proper POSIX sh.

Small gripe, but easy to fix ;)

Link to comment
Share on other sites

It is safe to assume bash is installed iff one is running Linux. All bets are off on other systems. Generally, even on Linux systems, when bash is invoked as sh it is trying to emulate sh behavior even though bash features still seem to work.

In my opinion, the pushd isn't needed. The directory the script was executed from would be restored when the subshell exits (if that is the intended function of using pushd). So, we can simply replace it with cd.

The following would be more portable and, everyone can be happy:

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">#!/bin/sh

cd bin

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib ./SpaceVikings

exit 0</pre>

Link to comment
Share on other sites

×
×
  • Create New...