<project name="Grunt Salesforce Ant Retrieve" default="retrieve" xmlns:sf="antlib:com.salesforce">

  <target name="retrieve">
    <% if(proxy_http) { %>
    <setproxy proxyhost="<%= proxy_http %>" proxyport="<%= proxy_port %>"/>
    <% } %>
    <sf:retrieve 
      <% if(sessionid) { %> 
      sessionId="<%= sessionid %>"
      <% } else { %>
      username="<%= user %>" 
      password="<%= pass %>"
      <% } %>
      serverurl="<%= serverurl %>" 
      maxPoll="<%= maxPoll %>" 
      pollWaitMillis="<%= pollWaitMillis %>" 
      apiVersion="<%= apiVersion %>"
      retrieveTarget="<%= retrieveTarget %>"
      <% if(packageNames) { %>
      packageNames="<%= packageNames %>"
      <% } else { %>
      unpackaged="<%= unpackaged %>"
      <% } %>
      unzip="<%= unzip %>">
    </sf:retrieve >
  </target>

</project>
<project name="Grunt Salesforce Ant Retrieve" default="retrieve" xmlns:sf="antlib:com.salesforce">

  <target name="retrieve">
    <% if(proxy_http) { %>
    <setproxy proxyhost="<%= proxy_http %>" proxyport="<%= proxy_port %>"/>
    <% } %>
    <sf:retrieve 
      <% if(sessionid) { %> 
      sessionId="<%= sessionid %>"
      <% } else { %>
      username="<%= user %>" 
      password="<%= pass %>"
      <% } %>
      serverurl="<%= serverurl %>" 
      maxPoll="<%= maxPoll %>" 
      pollWaitMillis="<%= pollWaitMillis %>" 
      apiVersion="<%= apiVersion %>"
      retrieveTarget="<%= retrieveTarget %>"
      <% if (typeof packageNames != 'undefined' && packageNames) { %>
      packageNames="<%= packageNames %>"
      <% } else { %>
      unpackaged="<%= unpackaged %>"
      <% } %>
      unzip="<%= unzip %>">
    </sf:retrieve >
  </target>

</project>

Handle when packageNames is undefined
Handle when packageNames is undefined

The line that checks for truthiness of the packageNames var throws an error if the var is undefined. This commit adds an extra check for undefined before checking for truthiness.