Skip to content

Instantly share code, notes, and snippets.

@justin2004
Last active February 1, 2024 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justin2004/def8af12867e1868bc57337a1b39aedd to your computer and use it in GitHub Desktop.
Save justin2004/def8af12867e1868bc57337a1b39aedd to your computer and use it in GitHub Desktop.
Dyalog APL/S-64 Version 18.2.45405 -- dyalogscript reading inconsistently from /dev/stdin
# let's read from /dev/stdin
$ cat some.apl
⍝⎕←⍴⊃⎕NGET 'zeros.txt'
⎕←⍴⊃⎕NGET '/dev/stdin'
$ dd if=/dev/zero count=1 bs=100000 | dyalogscript <(cat some.apl)
1+0 records in
1+0 records out
100000 bytes (100 kB, 98 KiB) copied, 0.0149497 s, 6.7 MB/s
100001
# notice above that dd finished and output to stderr and dyalogscript read in all the bytes.
# that is as expected -- 100000 + 1 newline character.
# but if we send in more bytes...
$ dd if=/dev/zero count=100 bs=100000 | dyalogscript <(cat some.apl)
100001
$ dd if=/dev/zero count=100 bs=100000 | dyalogscript <(cat some.apl)
130369
# notice above that dd doesn't finish and output to stderr and dyalogscript doesn't read in a consistent amount of bytes.
# but if we first write the bytes to a file and read from that file...
$ dd if=/dev/zero count=1000 bs=100000 > zeros.txt
1000+0 records in
1000+0 records out
100000000 bytes (100 MB, 95 MiB) copied, 0.259264 s, 386 MB/s
$ cat some.apl
⎕←⍴⊃⎕NGET 'zeros.txt'
⍝⎕←⍴⊃⎕NGET '/dev/stdin'
$ dyalogscript <(cat some.apl)
100000001
$ dyalogscript <(cat some.apl)
100000001
# then dyalogscript reads in all of the bytes consistently.
# why doesn't dyalogscript read all the bytes from /dev/stdin consistently?
# inside a docker container running docker image dyalog/techpreview:19.0
#
dyalog@ecae2a813db9:/mnt$ cat some.apl
⍝⎕←⍴⊃⎕NGET 'zeros.txt'
⎕←⍴⊃⎕NGET '/dev/stdin'
dyalog@ecae2a813db9:/mnt$ /opt/mdyalog/19.0/64/unicode/scriptbin/dyalogscript some.apl
Stream 3: MOD: line : 1 can't open. "/"
dyalog@ecae2a813db9:/mnt$ /opt/mdyalog/19.0/64/unicode/scriptbin/dyalogscript <(cat some.apl)
script file "/dev/fd/63" could not be found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment