title: To fix a bug in Less' command by noting no. of parameters
body: <p>This question is based on <a href="https://stackoverflow.com/questions/1053707/unable-to-make-a-shell-function-in-bash-zsh">this thread</a>.</p>
  
  <p><strong>The code</strong></p>
  
  <pre><code>function man()
  {       
      man "$1" &gt; /tmp/manual; less /tmp/manual 
  }
  </code></pre>
  
  <p><strong>Problem:</strong> if I use even one option, the command does not know where is the wanted-manual</p>
  
  <p>For instance,</p>
  
  <pre><code>man -k find
  </code></pre>
  
  <p>gives me an error, since the reference is wrong. The command reads <code>-k</code> as the manual.</p>
  
  <p><strong>My attempt to solve the problem in pseudo-code</strong></p>
  
  <pre><code>if no parameters
      run the initial code
  if one parameter
      run: man "$2"
  ...
  </code></pre>
  
  <p>In other words, we need to add an option-check to the beginning such that</p>
  
  <p><strong>Pseudo-code</strong></p>
  
  <pre><code>    man $optional-option(s) "$n" &gt; /tmp/manual; less /tmp/manual
  </code></pre>
  
  <p>where $n</p>
  
  <ul>
  <li>n=1 if zero options</li>
  <li>n=2 if 1 option</li>
  <li>n=3 if 2 options</li>
  <li>....</li>
  </ul>
  
  <p><strong>How can you make such an "option-check" that you can alter the value of $n?</strong></p>
  
  <p><strong>Developed Problem:</strong> to make two if loops for the situations from n=1 to n=2</p>