Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: script(1) bug?
On Fri, Aug 28, 2026 at 10:15:04 +0200, Thomas Klausner wrote:
> jq has set up a NetBSD runner on github (i.e. using qemu) and reports
> a weird problem in script: When the command returns too quickly, the
> output file is empty.
>
> https://github.com/jqlang/jq/pull/3600#issuecomment-5449885827
>
> I can't reproduce this on my (bare-metal) machine, can someone please
> try to reproduce it?
>
> for i in $(jot 100); do
> : > typescript
> script -qc echo > /dev/null
> [ ! -s typescript ] && echo ERROR
> done | uniq -c
Ah, we are probably trying to reproduce it wrong. script behaves
differently when stdin is not a terminal, as RTFS suggests. And
indeed: consider
runme() {
rm typescript
script -q -f -c 'echo foo; sleep 10;' < /dev/null > /dev/null
ls -l typescript
hexdump -C typescript
}
And then you race:
$ runme
-rw-r--r-- 1 uwe uwe 5 Aug 28 13:44 typescript
00000000 66 6f 6f 0d 0a |foo..|
00000005
$ runme
-rw-r--r-- 1 uwe uwe 0 Aug 28 13:46 typescript
$runme
-rw-r--r-- 1 uwe uwe 0 Aug 28 13:44 typescript
00000000 66 6f 6f 0d 0a |foo..|
00000005
-uwe
Home |
Main Index |
Thread Index |
Old Index