About

Welcome to Panela, Matt Harrison's take on mostly Open Source, Linux, Python, innovation in those areas, other buzzwords and Dick Proenneke. It comes complete with the illustrations as needed. Note the opinions expressed here are merely my opinions and not the opinions of my employer.

about Matt

Calendar

««Nov 2009»»
SMTWTFS
1234567
8910
11
12
1314
151617
18
192021
22232425262728
2930

Mailing List

My RSS Feeds








Why doesn't pushd popd work in my Ubuntu shell script?

posted 2008.06.26 Thu

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
#!/bin/bash
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.

tags:              

links: digg this    del.icio.us    reddit




1. No One left...
2008.06.27 Fri 4:24 pm

Because your shell is bash.

dash is used by default as the script interpretter, but bash is still the default shell (because dash is too spartan for most people's tastes).