Re: [PATCH 4/8] doc: simplify the handling of interruptions
Show 11 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
> > +"${args[@]}" -o "$out" "$1" ||
> > +{ rm -f "$out"; false; }
>
> It would be so nice if this worked, but here is what I saw in a
> quick-and-dirty experiment:
>
> $ f hoi || rm hoi ;# wait a bit and hit ^C
>
> So, I suspect it unfortunately may not work well.That's because the interrupt signal is not caught.
This works:
sh -c 'echo foo >"$1" && trap "exit 1" INT && sleep 20' test hoi || rm hoi
And so does this:
#!/bin/sh
ruby - hoi <<EOF || rm hoi
File.write(ARGV[0], 'foo')
begin
sleep(10)
rescue Exception
exit(1)
end
EOFBoth asciidoc and asciidoctor trap the signal.
> We need to get 2/8 redone without bash-ism,
Yes, if we agree this approach is indeed desirable I can do that.
Cheers.
--
Felipe Contreras