RichiH/vcsh — pull request #92 by archwyrm (2013-12-01 22:05:33+00:00)
Title: Fix missing blank repository name when cloning

If the repository path given to 'vcsh clone' contains a trailing slash (as introduced by tab completion, e.g.: file:///path/to/repo/), the resulting cloned directory will be '.git' and vcsh will not recognize the cloned repository by name. This change ensures that a trailing slash will be stripped and the repository name will be populated.

The previous faulty behavior is due to the custom implementation of the basename command first introduced in 794f0aac.

Compare the following output:

$ file=foo/bar/
$ echo "${file##*/}"

$ basename $file
bar
$ basename --version | head -1
basename (GNU coreutils) 8.21

The only trouble with this solution as opposed to the basename command, is it does not trim multiple trailing slashes (which the shell seems to have to no trouble with). Obviously a handy regex could fix this, but this would defeat the purpose of replacing basename in the first place (performance).