ndbroadbent/scm_breeze — pull request #75 by grundprinzip (2013-01-08 14:43:57+00:00)
Title: Fix for numbered directories or files

This commit fixes some odd behavior for numbered files and directories. Even if the environment variables is undefined cd'ing into a numbered directory is not possible.

Below see a short shell transcript showing the issue from a plan bash shell.

bash-3.2$ pwd
/tmp/test
bash-3.2$ git init
Initialized empty Git repository in /private/tmp/test/.git/
bash-3.2$ ga
bash: ga: command not found
bash-3.2$ mkdir 200
bash-3.2$ cd 200
bash-3.2$ pwd
/tmp/test/200
bash-3.2$ cd ..
bash-3.2$ source ~/.scm_breeze/scm_breeze.sh
bash-3.2$ ga
Usage: ga => git add
ga 1 => git add $e1
ga 2-4 => git add $e2 $e3 $e4
ga 2 5-7 => git add $e2 $e5 $e6 $e7

Note: Deleted files will also be staged using this shortcut.
To turn off this behaviour, change the 'auto_remove' option.
bash-3.2$ cd 200
bash-3.2$ pwd
/Users/grund

As you can see, I start in a blank folder and initialize a new git repository, then I create a folder called 200 and cd into it. After sourcing the scm_breeze.sh script I can no cd into the directory if it is the only path component.

This patch fixes this behaviour by performing a check if the file or folder exists before applying the substitution for the environment variable for wrapped commands.