sean finney on 1 Oct 2009 14:41:22 -0700


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

Re: [PLUG] POSIX shell equivalents of pushd and popd


heya,

On Thu, Oct 01, 2009 at 05:03:41PM -0400, K.S. Bhaskar wrote:
> I can't think of anything better than:
> 
> dirtmp="$PWD;$dirtmp" ; cd xxx # pushd
> cd `echo $dirtmp | cut --delimiter ";" --fields=1` ; dirtmp=`echo
> $dirtmp | cut --delimiter=";" --fields=2-` # popd

and then hope you don't ever need to pushd/popd a directory with a
semicolon in it's name :)

if you want to get super paranoid, you can quote the individual
directories and then store them as a space seperated list.  i wrote
about something similar a few months back[1][2] in the context of
positional parameters, but i think it's the same basic problem.


	sean

[1] http://www.seanius.net/blog/2009/03/saving-and-restoring-positional-params/
[2] http://www.seanius.net/blog/2009/03/saving-and-restoring-positional-params-redux/

Attachment: signature.asc
Description: Digital signature

___________________________________________________________________________
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