Changing paths with eval and a script
I work on multiple copies of a complex project simultaneously. To ease navigation, I use aliases to "cd" to the paths I use most often.
I cannot hardcode absolute paths, however, because each copy of the project has a different parent directory, e.g.
/home/me/proj/work1/...<full project>
/home/me/proj/work2/...<full project>
The root of each project is identifiable by a .git directory. (This is a simplified description - yes, I know git can save me the trouble of having multiple copies of the same project).
So I have a "findroot" script that walks up until it finds the .git. And it can take a new destination path...
/home/me/proj/work1/path/to/some/area$ findroot
cd ../../../../
/home/me/proj/work1/path/to/some/area$ findroot path/to/new/area
cd ../../../../path/to/new/area
Then I eval that script so that I can change the directory in the calling shell, e.g.
$ alias cdroot='eval `findroot $*`'
The problem is, that the $* seems to get ignored. If I do:
/home/me/proj/work1/path/to/some/area$ cdroot path/to/new/area
/home/me/proj/work1$
It only goes to the root and ignores path/to/new/area.
How do I get the argument to cdroot to get passed in as the argument to findroot via the $* ?
Any help would be appreciated.
|