I'm in the process of moving over to my new laptop. I run into an issue where a shell script (that worked under gentoo) now no longer works. Here's the error

foo.sh: 18: pushd: not found

Since I'm running this as

sh foo.sh

I turn on debugging with

sh -x foo.sh

Which doesn't help because the result is the same. Weird! I can run them from the command line.

Some searching led to my answer. Pushd and popd, are actual binaries, but are builtin to the shell. The default shell in ubuntu, dash doesn't have these commands. So I need to either invoke my shell as

bash foo.sh

or put


as the first line and chmod it, and execute it directly. Now as to why pushd/popd work from the command line, still haven't figured that out because shell is bash.