Relative paths are tricky. They work differently on each platform. os.getcwd() can always show you the working directory, which is useful since relative paths are relative to the working directory. Anyway, here’s the breakdown:
If you open Blender directly, then os.getcwd() will return /home/currentuser. So all paths are relative to home/currentuser. Also, if you open the .blend by double-clicking it, os.getcwd() will still return /home/currentuser (at least in Nautilus on Gnome it works that way… don’t know much about KDE, etc.).
However, if you open a terminal and navigate to the directory the .blend is in, then run Blender from that directory, os.getcwd() will return whichever directory you started Blender in. So using your example paths from above, you should do this this:
user@computer:~$ cd /home/user/whatever
user@computer:~/whatever$ blender foo.blend
Blender will then be able to find goo.wav from the relative path ./sfx/goo.wav. Also, as someone else mentioned, if you make a runtime, the relative paths will be correct.
It is important to note that on Linux Blender, the working directory never changes (unless you change it with os.setcwd() or whatever that command is). So if you use a Game Actuator to launch ./levels/level1.blend, the working directory will still be /home/user/whatever, not /home/user/whatever/levels (as it would be on Windows).
I don’t believe that I have run os.getcwd() on a Mac since Blender 2.44, but I imagine the behavior is still the same, since I haven’t heard of a bug fix for the issue. When I did run the function, I was very disappointed with what I found. On Macs it doesn’t matter how you open Blender, os.getcwd() will always return the root level directory (that is, / ). You need to either use absolute paths in your game, or you need to put a configuration file in the root level directory to point to your game directory.
If you open Blender directly, then use File >> Open to open your file, os.getcwd() will return the Blender directory (usually C:\Program Files\Blender Foundation\Blender). However, if you double-click the .blend file in Windows Explorer or My Computer, os.getcwd() will return the directory that the .blend is residing in. The same holds true with runtimes.
On Windows, os.getcwd() changes as you navigate through directories. Imagine your .blend is in C:\Documents and Settings\User\whatever and you use the Game Actuator to launch \levels\level1.blend. From inside level1.blend, os.getcwd() will return C:\Documents and Settings\User\whatever\levels.
I am of the opinion that the file path behavior needs to be standardized between all operating systems so that we do not have to write different .blends and scripts for each different scenario (as I am having to do for my current game project).
It seems to me that of the three behaviors, the Linux behavior is the most correct. From a structural perspective, the current working directory should always be the directory of the main game file, not the directory of the current .blend. This standardizes relative paths across all .blends in the game, so sound effects will always be in the ./sfx folder of the main game folder, regardless of what directory the working .blend is in.
Hope that helps.
To all: If I was wrong about any of the info above, please let me know so that I can correct it.