title: Git doesn't create .gitconfig when it's inside a function
body: <p>I'm a fairly new user in Bash and Git in general and I'm scratching my head about what the problem could be. I'm creating a code that checks if .gitconfig exists and if it doesn't it allows you to configure it almost automatically using a read command to get your email and username and apply them in a line of code.</p>
  <p>Code example:</p>
  <pre><code>#!/bin/bash
  
  # colors
  RED='\033[0;31m'
  GREEN='\033[0;32m'
  YELLOW='\033[1;33m'
  NO_COLOR='\033[0m'
  
  # function git
  git () { 
     printf &quot;${RED}Set your Git email\n${NO_COLOR}&quot;
     read GIT_AUTHOR_EMAIL
     git config --global user.email &quot;$GIT_AUTHOR_EMAIL&quot;
     printf &quot;${RED}Set your Git username\n${NO_COLOR}&quot;
     read GIT_AUTHOR_USERNAME
     git config --global user.name &quot;$GIT_AUTHOR_USERNAME&quot;
     git config --list | grep user.email &amp;&amp; git config --list | grep user.name
  }
  
  # git check &amp; configuration
  if [ -f &quot;.gitconfig&quot; ]; then
     printf &quot;${YELLOW}Git was previously configured\n${NO_COLOR}&quot;
     exit
  else
     git
     printf &quot;${YELLOW}Done\n${NO_COLOR}&quot;
     exit
  fi
  </code></pre>
  <p>If it doesn't exist, it calls a function to configure it but after some quick debugging using the <code>set -x</code> command I figured out the file .gitconfig is not created at all but it does when I do it myself outside a function. All it does is go back to <code>read GIT_AUTHOR_EMAIL</code>, apply the code <code>git config --global user.email &quot;$GIT_AUTHOR_EMAIL&quot;</code> and go back to the first read command. I want the code to check for .gitconfig and if it exists it'll also ask if the user wants to re-configure their Git details. I'm super close on doing so.</p>
  <p>Is there any way I can fix it or do it another way?</p>