title: Editing sudoers in OS X (10.7)
body: <p>I've got a script (written by my predecessor) which successfully edits the sudoers file on a Mac running OS X 10.6; it goes like this: </p>
  
  <pre><code>#!/bin/sh
  
  if [ -z "$1" ]; then
      export EDITOR=$0 &amp;&amp; sudo -E visudo
  else
      echo "%staff ALL=NOPASSWD: /sbin/shutdown" &gt;&gt; $1
  fi
  </code></pre>
  
  <p>However, when run on a Mac running 10.7, instead of adding the line to the sudoers file, it launches visudo "interactively". It does not seem to enter the "else" clause at any point. I suspect that the appropriate syntax of line 4 ("export...") has changed, but I can't seem to find out how. Any pointers?</p>
  
  <p>Since someone will ask: We have an elaborate (and admittedly, somewhat silly, but necessarily so) forced-reboot schedule for patching. If a user has not rebooted willfully by the deadline, an application will launch with a  5 minute countdown (or the option to reboot immediately) at which point the 'sudo shutdown -r now' command is issued. For my sanity's sake, please don't ask me to defend the nature of this arrangement. It is outside of my control.</p>