JP Vossen on 14 Aug 2010 12:24:54 -0700


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

Re: [PLUG] /bin/sh alternative to bash's pushd and popd


Date: Fri, 13 Aug 2010 15:58:16 -0400
From: "K.S. Bhaskar"<bhaskar@bhaskars.com>

Is there any way to implement (possibly with some coding)
functionality analogous to bash's directory stack but with /bin/sh?  I
am trying to write a shell script that may have to execute on sh.
Thanks in advance.

Yes, Cameron covers that on pages 103-106 in _Learning the bash Shell 3_ (and I understand he's working on the 4th edition).

Be sure to read the whole section because there are some caveats. Also, he is implementing these in bash, so it's possible these functions won't work in sh. I *think* they will work from a quick eyeball, but I don't really ever use sh, so... Here's the code:
http://books.google.com/books?id=YLSw9FCL37sC&pg=PA105&lpg=PA105&dq=%22next,+we+need+to+implement+pushd+and+popd+as+functions.++Here+are+our+initial+versions%22&source=bl&ots=2jBG6yLQnR&sig=9p7eaN1kXTX90UeD0RVzC_xQIqQ&hl=en&ei=zutmTNiZBoG78gaa0IC0BA&sa=X&oi=book_result&ct=result&resnum=3&ved=0CBcQ6AEwAg

They might at least provide a place to start.

HTH,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|      http://bashcookbook.com/
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"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         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug