home *** CD-ROM | disk | FTP | other *** search
- #!c:sksh
-
- #*************************************************************************
- # This function implements the popd operation. It accepts no arguments,
- # and simply pops a directory off the stack and returns to that point.
- # it complains if the directory stack is empty.
- #*************************************************************************
-
- local _new_dir
-
- if [ "$#" -ne '0' -o "$1" = '-?' ]
- then
- echo 'Usage:' $(basename $0)
- echo ' (pops directory from directory stack)'
- return 1
- fi
-
- # --- if the DIRSTACK is empty, print that fact and exit ------------------
-
- [ -z "$DIRSTACK" ] && echo 'The directory stack is empty' && return 1
-
- # --- extract the new directory and remove it from the DIRSTACK -----------
-
- _new_dir = $(car "$DIRSTACK" ',')
- DIRSTACK = $(cdr "$DIRSTACK" ',')
- export -l DIRSTACK
-
- # --- cd to the new place and complain if we can't ------------------------
-
- cd "$_new_dir" >nil: || echo "$0: Can't cd to $_new_dir."
-