pushd

来自「Berkely的学生写的」· 代码 · 共 35 行

TXT
35
字号
#!/bin/sh# Chapter 14 - Functions# This script implements the csh command pushd and pushes a# directory onto the directory stack.# You will need to "source" this file into your environment# using the . command.pushd() {    # set the requested directory, $REQ, to the first argument    # If no argument is given, set REQ to .    REQ="$1";     if [ -z "$REQ" ] ; then REQ=. ; fi    # if $REQ is a directory, cd to the directory    # if the cd is successful update $_DIR_STACK    # otherwise issue the appropriate error messages    if [ -d "$REQ" ] ; then        cd "$REQ" > /dev/null 2>&1        if [ $? -eq 0 ] ; then            _DIR_STACK="`pwd`:$_DIR_STACK" ; export _DIR_STACK ;            dirs        else            echo "ERROR: Cannot change to directory $REQ." >&2        fi    else        echo "ERROR: $REQ is not a directory." >&2    fi    unset REQ}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?