Fix for numbered directories or files #75

Merged
merged 1 commit into from Jan 8, 2013

Projects

None yet

2 participants

Contributor

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 <file>  => git add <file>
       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.

@grundprinzip grundprinzip 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. This pathc
fixes this by checking if the argument is a valid
file or directory and is numnbered and if this is the case will
only output the argument values instead of a substitution with $e..

In case there exist both, numbered valid argument and the
directory or folder, the file will always win to avoid clashes with
standard wrapped functions like cd, rm, mv...
fcf5dd3
Collaborator

Awesome, thanks! Great solution

@ndbroadbent ndbroadbent merged commit e785ff6 into scmbreeze:master Jan 8, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment