title: Execute command in all immediate subdirectories
body: <p>I'm trying to add a shell function (zsh) <code>mexec</code> to execute the same command in all immediate subdirectories e.g. with the following structure</p>
  
  <pre><code>~
  -- folder1
  -- folder2
  </code></pre>
  
  <p><code>mexec pwd</code> would show for example </p>
  
  <pre><code>/home/me/folder1
  /home/me/folder2
  </code></pre>
  
  <p>I'm using <code>find</code> to pull the immediate subdirectories. The problem is getting the passed in command to execute. Here's my first function defintion:</p>
  
  <pre><code>mexec() {
      find . -mindepth 1 -maxdepth 1 -type d | xargs -I'{}' \
      /bin/zsh -c "cd {} &amp;&amp; $@;";
  }
  </code></pre>
  
  <p>only executes the command itself but doesn't pass in the arguments i.e. <code>mexec ls -al</code> behaves exactly like <code>ls</code></p>
  
  <p>Changing the second line to <code>/bin/zsh -c "(cd {} &amp;&amp; $@);"</code>, <code>mexec</code> works for just <code>mexec ls</code> but shows this error for <code>mexec ls -al</code>:</p>
  
  <pre><code>zsh:1: parse error near `ls'
  </code></pre>
  
  <p>Going the exec route with find</p>
  
  <pre><code>find . -mindepth 1 -maxdepth 1 -type d -exec /bin/zsh -c "(cd {} &amp;&amp; $@)" \;
  </code></pre>
  
  <p>Gives me the same thing which leads me to believe there's a problem with how I'm passing the arguments to zsh. This also seems to be a problem if I use bash: the error shown is:</p>
  
  <pre><code>-a);: -c: line 1: syntax error: unexpected end of file
  </code></pre>
  
  <p>What would be a good way to achieve this?</p>