On Thu, 17 Feb 2011, Spencer E. Olson wrote: > We are not actually using the yes utility (think y\ny\ny\ny\ny\ny\n...) > > As far as I understand, in this particular use, "yes" and "no" are just > comments. We could also write > : I like banannas ;; > and > ! : I do not like anchovies ;; Ah, I'm sure you're right. Need to read up on that colon operator. Thanks. > > On Thursday 17 February 2011 17:34, Martin von Zweigbergk wrote: > > On Thu, 17 Feb 2011, Johannes Sixt wrote: > > > Am 2/16/2011 20:51, schrieb Junio C Hamano: > > > > Here is how to write the above more concisely, efficiently and > > > > portably. > > > > > > > > case "$2;" in > > > > *";$1;"*) > > > > echo yes ;; > > > > *) > > > > echo no ;; > > > > esac > > > > > > > > The trailing ';' takes care of the case where cloned_modules has only > > > > one element, in which case you have ";name" in "$2". No need for a > > > > loop. > > > > > > And while you are here, you could make this: > > > > > > list_contains() > > > { > > > case "$2;" in > > > *";$1;"*) > > > > > > : yes ;; > > > > > > *) > > > ! : no ;; > > > esac > > > } > > > > > > and test for the exit code of this function rather than its output at the > > > call site. > > > > According to Brandon Casey: "Some platforms (IRIX 6.5, Solaris 7) do > > not provide the 'yes' utility." See 8648732 (t/test-lib.sh: provide a > > shell implementation of the 'yes' utility, 2009-08-28). > > > > > > /Martin > -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html