Programming Anti-patterns in Shell and Perl Scripts

Ryan Johnson
Tue Jun 28 19:21:00 GMT 2011

On 28/06/2011 2:53 PM, Sravan Bhamidipati wrote:
> Hello Cygwin. :-)
> I have been working on static code analysis from a performance
> perspective, and I recently applied the concept to Shell and Perl
> scripts. The most basic idea was to look for usages of Unix commands,
> their combinations with pipes, and stuff like that to which
> alternatives using Shell built-ins (or Perl functions) could be
> possible. e.g. Using ((num++)) instead of `expr $num + 1`. In examples
> where I had "fixed" anti-patterns, there was often a noticeable
> improvement (mostly realized in the form of faster runtime). I have
> also written a dirty parser and put together basic "guides" to go
> about this:
> Among Cygwin packages, bash-completion has some of the highest
> programming anti-patterns, but there are various others as well. Does
> this seem like a useful idea? If it is, what could be a good way of
> going about implementing it?
I don't use bash-completion myself, but my understanding is that it can 
be very slow, if for no other reason than fork() is slow in cygwin. If 
your de-anti-pattern transformation causes fewer calls to fork() -- and 
the above expr example suggests it does -- it could be very worthwhile.

Implementation-wise, you probably want to start here:


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list