title: String manipulation in fish shell
body: <p>i wish to write a fish shell script to automatically initialize JAVA_HOME to current configured java-alternative.</p>
  
  <p>In bash it would look like this (sorry for the ugly double dirname)</p>
  
  <pre><code>j=`update-alternatives --query javac | grep Value:`
  JAVA_HOME=`dirname ${j#Value:}`
  JAVA_HOME=`dirname $JAVA_HOME`
  export JAVA_HOME
  </code></pre>
  
  <p>what about fish?</p>
  
  <pre><code>set j (update-alternatives --query javac | grep Value:)
  set JAVA_HOME (dirname ${j#Value:}) &lt;-- this won't work!!
  set JAVA_HOME (dirname $JAVA_HOME)
  set --export JAVA_HOME
  </code></pre>