title: Resolving submodule paths in git
body: <p>I'm trying to create helper to select desired git submodule. Very simple thing:</p>
  
  <pre><code>    modules=`git submodule | sed 's/.* \(.*\) (.*/\1/'`;
      select var in $modules; do 
          echo $var; 
          break; 
      done
  </code></pre>
  
  <p>My repo structure looks like this:</p>
  
  <pre><code>    /
      |-dir1
      |   |-submodule1
      |-dir2
          |-submodule1
  </code></pre>
  
  <p>When I save script above as executable file and run it from shell, I see correct relative paths to submodules, like this:</p>
  
  <pre><code>    $ cd dir1
      $ git-submodule-select
      1) submodule1
      2) ../dir2/submodule2
      #?
  </code></pre>
  
  <p>But, if I try to save same command as a git alias in my .gitconfig, it always shows paths relative to repo's root, no matter where I am:</p>
  
  <pre><code>    [alias]
          subs = "!f() { \
              modules=`git submodule | sed 's/.* \\(.*\\) (.*/\\1/'`; \
              select var in $modules; do  \
                  echo $var; \
                  break;  \
              done; \
          }; f"
  
      $ cd dir1
      $ git subs
  
      1) dir1/submodule1
      2) dir2/submodule2
      #?
  </code></pre>
  
  <p>Why this happens? I need paths, relative to my current location - can it be done through git aliases at all? Or I must use only global functions?</p>