Search code examples
gitbashscriptingbash-function

bash function ignoring dot for git clone command


I am wrestling with a bash function that will not clone to current directory, it is making a project folder:

cloneproject() { git clone [email protected]:codyc54321/$1.git . ;}

I have the dot at the end, before semicolon, but running this within a directory named 'bookwormbuddy' makes it add a new project folder as if you ran clone without a dot:

me@pc:~/projects/bookwormbuddy$ cloneproject bookwormbuddy
Cloning into 'bookwormbuddy'...

Yet when I run the same command from terminal, it works as I'm used to:

me@pc:~/projects/bookwormbuddy$ git clone [email protected]:codyc54321/new_bookmarks.git .
Cloning into '.'...

I need this as I name projects different in storage for reasons. How can I make ubuntu respect the dot? Thank you


Solution

  • You can escape the dot to tell the Bash not to treat it as part of a regular expression:

    cloneproject() { git clone [email protected]:codyc54321/$1.git \. ;}
    

    As this SO post discusses, Bash will treat a single dot as meaning "any character."