[Vm-dev] Re: conditionally define a function in sh/bash?

phil at highoctane.be phil at highoctane.be
Sun Jun 22 14:18:53 UTC 2014


On Sun, Jun 22, 2014 at 12:54 PM, <btc at openinworld.com> wrote:

>
>  Eliot Miranda wrote:
>
>
> ------------------------------
>
>
>
>
> On Thu, Jun 19, 2014 at 5:17 PM, Eliot Miranda <eliot.miranda at gmail.com>
> wrote:
>
>> Hi All,
>>
>>      I'm trying
>>
>>  if [ "$OS" = Darwin ]; then
>>     function quietmd5 () { /sbin/md5 -q "$1"; }
>> else
>>     function quietmd5 () { /usr/bin/md5sum "$1"| sed 's/ .*$//'; }
>> fi
>>
>
>  this works:
>
>  test "$OS" = Darwin && function quietmd5 () { /sbin/md5 -q "$1"; }
> test "$OS" != Darwin && function quietmd5 () { /usr/bin/md5sum "$1"| sed
> 's/ .*$//'; }
>
>  --
> best,
> Eliot
>
>
> nice technique.
> cheers -ben
>

This one goes to my cheat sheet :-)

Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20140622/de670710/attachment.htm


More information about the Vm-dev mailing list