Learn R Programming

cgwtools (version 4.1)

pushd: Performs equivalent of bash command with same name

Description

pushd is based on the cygwin bash manpages' description of these commands.

Usage

pushd(path, dn=FALSE,rot=0)

Value

A status value, which is always 0 for success. A future upgrade may implement a trycatch for conditions such as an inaccessible directory, but for now error messages will have to suffice.

Arguments

path

The directory to move into.

dn

Equivalent of the dir argument in bash . When TRUE, adds the current directory to the stack.

rot

Equivalent of the n argument in bash. Rotates the existing stack by the value of rot ; can be positive or negative. Note that there may be some inconsistency in how this is handled in different implementations of bash .

Author

Carl Witthoft carl@witthoft.com

Details

Recommend reading man bash for full details of the operations. This implementation should do nothing more than change the working directory (and store directory history in a file in the function's environment (not console environment) .dirhist ).

See Also

popd , setwd

Examples

Run this code
## depends on your local directory structure and permissions
getwd()
pushd("~/..")
getwd()
popd()
getwd()

Run the code above in your browser using DataLab