Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: What would you say is the most-used way of indenting case labels



"Nikolai Weibull" wrote:
> That is, is this style:
> 
> case something in
> (*ome*)
>   ... ;;
> esac
> 
> more common than
> 
> case something in
>   (*ome*)
>     ... ;;
> esac

I use Emacs sh-script mode and I end up with things looking like this

case foo in
  (bar)
  do_foo_bar
  ;;

  (rod)
  do_foo_rod
  ;;
esac

which is pretty much your second option, except there's no additional
indentation after the test and the separate ;; serves
as a visual end marker (like a "break" in C).  The zsh code seems to be
full of things like:

case foo in
  (bar)
    do_foo_bar
    ;;
  (rod)
    do_foo_rod
    ;;
esac

sometimes with a space between the ;; and the next test, sometimes without,
sometimes with the ;; level with the test, sometimes indented as shown.
However, there are other variations, too, including having the ";:" on the
same line as the last chunk of code, which seems to be more common when
there's only one line of executable code (which then sometimes appears on
the line with the test).

The only consensus seems to be the "(bar)" test is indented from the
"case".

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



Messages sorted by: Reverse Date, Date, Thread, Author