delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/08/22/15:32:31

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type:content-transfer-encoding;
q=dns; s=default; b=HoVSiFuAJgZSt3seRcJGd8DeF2abX6O2Cej6RszvETS
wBA9qwuLGV96gEuoBXBYAQqQuFEJLCj3G14cTw8J4F8Q2Ue7feun/7+viEm7jnk7
r2DT53AjhlaU8N+EBuUWcUV50CjeF48a0v5fG2NIu8nLatKgWkjY0fwA3B/8J8vg
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type:content-transfer-encoding;
s=default; bh=IsV6WY8e157Dl5zbYe43X6VgeVs=; b=WGrmcPcACEVj5LL+l
UgU9zPX9CEGrTW3C+fC69oWTy6LrrpyP756wMRdYkkW1/mrixpWaybE5K6hb2gKn
P+tgsKjFb0bGo+gDU4x7XUT9nbz6gnCy6TlvAwE7wTHJpuL4IyseKlbWE7nRm5Pp
U5vBhpG0mw97OjZO8E1dXoVGqE=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=cygsimplegmailcom, cygsimple AT gmail DOT com, H*f:sk:b12f15c, H*i:sk:b12f15c
X-HELO: mail-lf0-f44.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=USb/3yrG4MP89YDgtLsf2E0eoj3FFAx6ak50J7F0v0U=; b=eSJIAFmhunfL3Q5c+XO+bersX8XSSZ7qHyxCj4Fl6ZhS1lyMORHqJPvwBiJreDZ0Oc EOAyO3jMAvkiIR+w/ozfelaZ0p3aX/2Ha2Dv2PsB4MRHX6xaBBOpfB7VmrzHemRpXNEl MwLcX9R/5OqctfqcbAKBtd+GPOoztk/es1o3gOsJiC528nh4BuWjkID1+ybW9/nb4mP2 iCCe7qeJpYJHWYH3xg0FM0NjyrzljLGWiU0F/c1CCy92m4tCUinSStbySGhs1bmnw+b/ Axd+afL9YLWGEjDoc1C4EKrwtWF73Hlx3rIV6QRrE86SKDBNH6TzHiuVaHaT9nVpAo1j WMqA==
X-Gm-Message-State: AEkooutCJqI12jsF2nygp9JqiAh0z9kqEv5x32G71UmLMaVvQQm2zGMYcQeo1UJz0vjORrN/D8zcf2Tkh18QOw==
X-Received: by 10.25.163.132 with SMTP id m126mr6622454lfe.56.1471894323093; Mon, 22 Aug 2016 12:32:03 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <b12f15c3-121b-fea6-7dcf-a6c703434030@gmail.com>
References: <CA+7cx1oHkwK8vOV+2heYAhw=DhkrRfEvkbaj2pmH+x29ZP0T7Q AT mail DOT gmail DOT com> <fd1a102b-9df8-24b7-8440-9842b614fc6c AT gmail DOT com> <CA+7cx1p8ntAQriaYPJyBLcEu7sHPixs3sYUydx8XMZqQ20mL1g AT mail DOT gmail DOT com> <b12f15c3-121b-fea6-7dcf-a6c703434030 AT gmail DOT com>
From: =?UTF-8?Q?Morten_Kj=C3=A6rulff?= <mortenkjarulff AT gmail DOT com>
Date: Mon, 22 Aug 2016 21:31:42 +0200
Message-ID: <CA+7cx1p88=wQC=HTcYp8kgX4FFn=Z86Fa5bZDceh0u4TPYx5gg@mail.gmail.com>
Subject: Re: #!/bin/sh and #!/bin/bash is not the same
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id u7MJWQDQ017234

On Mon, Aug 22, 2016 at 8:51 PM, cyg Simple <cygsimple AT gmail DOT com> wrote:
> Please do not TOP POST.
>
> On 8/22/2016 10:36 AM, Morten Kjærulff wrote:
>> Thanks.
>>
>> What I was actually trying, was this:
>>
>> echo a | while read ; do
>>   some_command &
>> done
>> wait
>>
>> The "wait" did not wait. I guessed the reason was that "some_command
>> &" was executed in a subshell.
>>
>> So I tried:
>>
>> while read ; do
>>   some_command &
>> done < <(echo a)
>> wait
>>
>> It was working, however not with #!/bin/sh
>>
>
> What does ``/bin/sh --version'' print?
>
> The wait command is a shell internal command, there is no external
> equivalent. If you /bin/sh is bash then perhaps you've found a bug in
> the emulation of /bin/sh in bash.  Bash takes a different code path when
> named sh.
>
> --
> cyg Simple
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>


Sorry, I think I have been confusing.

This:

date
echo a | while read ; do
  sleep 3 &
done
wait
date

will run in 0 seconds, with BOTH /bin/sh and /bin/bash

This:

date
while read ; do
  sleep 3 &
done < <(echo a)
wait
date

will run in 3 seconds with /bin/bash and get syntax errors with /bin/sh:
syntax error near unexpected token `<'
`done < <(echo a)'

$ /bin/sh --version
GNU bash, version 4.3.46(6)-release (x86_64-unknown-cygwin)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

I believe all is ok.

/Morten

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019