Re: process substitution flawed by design

2017-02-21 Thread Florian Mayer
The following code assumes the lock to be in state not-taken before the snippet runs. echo foo | tee \ >(mutex --lock; echo before; cat; echo after; mutex --unlock) \ >(mutex --lock; echo foobar; mutex --unlock) \ > /dev/null | cat for mutex --lock I use a tool which I wrote myself

Re: process substitution flawed by design

2017-02-21 Thread Greg Wooledge
On Tue, Feb 21, 2017 at 02:18:03PM +0100, Florian Mayer wrote: > for mutex --lock I use a tool which I wrote myself. What does it do? > The following code assumes the lock to be in state not-taken before the > snippet runs. What lock? > echo foo | tee \ > >(mutex --lock; echo before; cat;

Re: process substitution flawed by design

2017-02-21 Thread Pierre Gaston
On Tue, Feb 21, 2017 at 4:00 PM, Pierre Gaston wrote: > > > On Tue, Feb 21, 2017 at 3:18 PM, Florian Mayer > wrote: > >> The following code assumes the lock to be in state not-taken before the >> snippet runs. >> >> echo foo | tee \ >> >(mutex --lock; echo before; cat; echo after; mutex --u

Re: process substitution flawed by design

2017-02-21 Thread Florian Mayer
What does it do? It behaves like the p-operation on unary Sys-V semaphores. If the semaphore has not been taken (has had the value 1), mutex --lock immediately exits. If the semaphore has indeed been taken already (has the value 0), mutex --lock will try to gain the lock and only exit if it wa

Re: process substitution flawed by design

2017-02-21 Thread Pierre Gaston
On Tue, Feb 21, 2017 at 3:18 PM, Florian Mayer wrote: > The following code assumes the lock to be in state not-taken before the > snippet runs. > > echo foo | tee \ > >(mutex --lock; echo before; cat; echo after; mutex --unlock) \ > >(mutex --lock; echo foobar; mutex --unlock) \ > >

Re: process substitution flawed by design

2017-02-21 Thread Greg Wooledge
On Tue, Feb 21, 2017 at 03:11:22PM +0100, Florian Mayer wrote: > >What does it do? > It behaves like the p-operation on unary Sys-V semaphores. OK, without digging any further into this morass, and without trying to guess whether you've found a bug in bash or in your own tool, can I just leave thi

Re: process substitution flawed by design

2017-02-21 Thread Chet Ramey
On 2/21/17 8:18 AM, Florian Mayer wrote: > The following code assumes the lock to be in state not-taken before the > snippet runs. > > echo foo | tee \ > >(mutex --lock; echo before; cat; echo after; mutex --unlock) \ > >(mutex --lock; echo foobar; mutex --unlock) \ > > /dev/null | ca

readonly changes set -e behavior

2017-02-21 Thread Dennis Kuhn
Hello, Configuration Information [Automatically generated, do not change]: Machine: Mac OS: Darwin Compiler: gcc Compilation CFLAGS: Xcode uname output: Darwin dkuhn 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64 Machine Type: x8

Re: readonly changes set -e behavior

2017-02-21 Thread Eduardo Bustamante
On Tue, Feb 21, 2017 at 11:02 AM, Dennis Kuhn wrote: [...] > > When the variable s is set to readonly the script does not exit and echoes > "abc": > > #!/bin/bash > set -e > > readonly s=$(false) > echo "abc" [...] This is a commonly reported issue. The moment you add the readonly builtin, you'r