title: cd to directory determined by pipelined commands
body: <p>I'm trying to parse a Window Title that contains a path and then cd to that directory. My command successfully returns the directory I want to go to but I'm getting weird problems when trying to cd to it. The window title looks like this: <code>C:\path\to\directory\file.cpp (bullet point)- Program name</code>.
  Because of the weird bullet point symbol I'm cutting on the . in .cpp and then getting the parent directory of what it thinks is a subdirectory but is really a file. Still works fine. The command is</p>
  
  <pre><code>cd $(dirname $(tasklist -fi "imagename eq sublime_text.exe" -fo list -v | grep "Window Title" | cut -f1 -d. | cut -d: -f2- | cut -c 2-) | sed 's/^/"/ ;s/$/"/')
  </code></pre>
  
  <p>When I replace cd with echo I get <code>"C:\path\to\directory"</code> and when I simply type cd and copy paste this quoted path that I get back it works. But it will not work in the command, I get <code>bash: cd: "C:\Users\twilliams\Documents\GitHub\Native\mcs\src\Lib": No such file or directory</code>. I have also tried putting quotes around the cd and dirname commands like so</p>
  
  <pre><code>cd "$(dirname "$(tasklist -fi "imagename eq sublime_text.exe" -fo list -v | grep "Window Title" | cut -f1 -d. | cut -d: -f2- | cut -c 2-)" | sed 's/^ /"/;s/$/"/')"
  </code></pre>
  
  <p>Additionally I tried it using echo instead of sed like so</p>
  
  <pre><code>cd "$(echo "\"$(dirname "$(tasklist -fi "imagename eq sublime_text.exe" -fo list -v | grep "Window Title" | cut -f1 -d- | cut -d: -f2- | cut -c 2-)") \"")"
  </code></pre>
  
  <p>In all of these cases I get the proper <code>"C:\path\to\directory"</code> output when echoing, and cding to this path manually works</p>
  
  <p>I'm using git bash on windows. Thoughts?</p>