JP Vossen on 25 Aug 2011 12:11:14 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] pushd and popd on debian squeeze

Date: Thu, 25 Aug 2011 14:35:20 -0400
From: Michael Lazin<>
Subject: [PLUG] pushd and popd on debian squeeze

Hi, I am trying to run a bash script on debian squeeze that uses pushd and
popd.  They are not in the path and when I got to the root directory as root
and type "find -name pushd" nothing comes up.  Why are these missing from
debian?  How can I get them?

> Date: Thu, 25 Aug 2011 14:40:45 -0400
> From: Douglas Muth <>
> They're shell commands.

True in bash. Note the bash 'help' command, which is *much* more useful than the 'man' command for builtins! See also the 'type -a' command. I thought 'which' was an alias to 'type -a' but at least on Squeeze it isn't. Huh.

/home/jp$ cat /etc/debian_version

/home/jp$ help pushd
pushd: pushd [-n] [+N | -N | dir]
    Add directories to stack.

/home/jp$ type -a pushd
pushd is a shell builtin

> Make sure your script starts with:
> #!/bin/bash
> and NOT:
> #!/bin/sh

It's slightly more secure to use (note trailing -):
	#!/bin/bash -
	#!/bin/sh -

I *think* I talked about that in

> While sh is usually symlinked to bash, if it's run as sh, it will
> emulate the Bourne Shell, and bash-specific commands like pushd and
> popd will not be available.

True on Debian, but watch out! That has *not* been true on Ubuntu for a while now, and it *will* get you in to trouble if you assume '/bin/sh' is really sorta-kinda bash. For details see

Short version: /bin/sh --> dash (*not* bash) on Ubuntu, and dash != bash! Heck, sh != bash != dash, while we're at it. "Portable" shell scripts can be really hard to write, that's partly why Perl exists. :-) (And no, I don't wanna hear about zsh Paul... ;-)

JP Vossen, CISSP            |:::======|
My Account, My Opinions     |=========|
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --