File talk:Hamilton C shell and Cygwin bash date loops.png

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Use has been authorized under terms of Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA).[edit]

The screen image is my own work, snapshotted on own machine running a licensed copy of the subject software product, Hamilton C shell. I have a forwarded an email exchange from the creator and owner of that product, Nicole Hamilton at Hamilton Laboratories, granting permission to use this image of her product (plus two others also used here on WP) under terms of Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA) to WP:OTRS as Ticket number 2017012310002162. Unfortunately, there is a backlog in processing. Msnicki (talk) 21:37, 22 January 2017 (UTC)[reply]

Misleading[edit]

While csh requires parentheses in while loops as part of syntax, in bash and other bourne shell derivatives the parentheses will actually spawn the enclosed command in a sub shell. The compared statements do not do the same thing. Is this in ignorance or intentional?

It should be

while true ; do date ; done | uniq -c

not

while ( true ) ; do date ; done | uniq -c

which would be roughly equivalent to

while bash -c true ; do date ; done | uniq -c

I don't doubt that this shell is faster in some things than some or most other shells ported to Windows, and in a quick test the sub shell loses me "only" around 50% performance vs. the factor-10 difference between bash and Hamilton shown here, but this is really not necessary.

-- 79.202.98.49 (talk) 23:55, 17 November 2018 (UTC)[reply]

Fair point. Thanks for pointing this out. It wasn't my intention to create an unfair comparison. My recollection is that I copied the bash loop as you see it in that screenshot uncritically from a Cygwin mailing list message, then wrote what I thought was a comparable C shell loop. I can confirm that in my tests, eliminating the extra parens sped up the bash date loop by about 60%. On the other hand, what this also highlights is that a bash subshell is rather slow. Adding extra parens around the date command in the C shell loop also creates a subshell, but the loop without the subshell is only about 25% faster. Msnicki (talk) 01:58, 9 June 2019 (UTC)[reply]