diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-20 16:26:06 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-20 16:26:39 +1200 |
commit | 6e3fd021588c87a0743dbc1ec5b3f5aba900f839 (patch) | |
tree | 74a790cf3a96c7f55660c612964462f194aa20ce /bash/bashrc.d | |
parent | Assume POSIX sh (diff) | |
download | dotfiles-6e3fd021588c87a0743dbc1ec5b3f5aba900f839.tar.gz dotfiles-6e3fd021588c87a0743dbc1ec5b3f5aba900f839.zip |
Port vr(1) to POSIX sh
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r-- | bash/bashrc.d/vr.bash | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/bash/bashrc.d/vr.bash b/bash/bashrc.d/vr.bash deleted file mode 100644 index adabb395..00000000 --- a/bash/bashrc.d/vr.bash +++ /dev/null @@ -1,59 +0,0 @@ -# Move to the root directory of a VCS working copy -vr() { - local path - path=${1:-"$PWD"} - path=${path%/} - - # Raise some helpful errors - if [[ ! -e $path ]] ; then - printf 'bash: %s: %s: No such file or directory\n' \ - "$FUNCNAME" "$path" - return 1 - fi - if [[ ! -d $path ]] ; then - printf 'bash: %s: %s: Not a directory\n' \ - "$FUNCNAME" "$path" - return 1 - fi - if [[ ! -x $path ]] ; then - printf 'bash: %s: %s: Permission denied\n' \ - "$FUNCNAME" "$path" - return 1 - fi - - # Ask Git the top level - local git_root - git_root=$(cd -- "$path" && git rev-parse --show-toplevel 2>/dev/null) - if [[ -n $git_root ]] ; then - cd -- "$git_root" - return - fi - - # Ask Mercurial the top level - local hg_root - hg_root=$(cd -- "$path" && hg root 2>/dev/null) - if [[ -n $hg_root ]] ; then - cd -- "$hg_root" - return - fi - - # If we have a .svn directory, iterate upwards until we find an ancestor - # that doesn't; hopefully that's the root - if [[ -d $path/.svn ]] ; then - local search - search=$path - while [[ -n $search ]] ; do - if [[ -d ${search%/*}/.svn ]] ; then - search=${search%/*} - else - cd -- "$search" - return - fi - done - fi - - # Couldn't find repository root, say so - printf 'bash: %s: Failed to find repository root\n' \ - "$FUNCNAME" >&2 - return 1 -} |