main pita/uxn12 / etc / ext / pwd.tal
 1( pwd.tal )
 2( )
 3( reads output of `pwd` and prints it )
 4
 5|00 @System
 6    |00 &vector $2
 7    |02 &expansion $2
 8    |04 &title $2
 9    |06 &metadata $2
10    |08 &r $2
11    |0a &g $2
12    |0c &b $2
13    |0e &debug $1
14    |0f &exit $1
15
16@Console
17    |10 &vector $2 ( called when input is ready )
18    |12 &read $1 ( read an input byte, e.g. from stdin )
19    ( 13 - 14 padding )
20    |15 &live $1 ( subprocess: 01 alive, ff dead, 00 not running )
21    |15 &exit $1 ( subprocess: exit code if dead )
22    |17 &type $1 ( input type: 01 stdin, 02 arg, 03 end of arg, 04 end of args )
23    |18 &write $1 ( byte to write to stdout )
24    |19 &error $1 ( byte to write to stderr )
25    ( 1a - 1b padding )
26    |1c &addr $2 ( subprocess: addr of string to run with /bin/sh -c )
27    |1e &mode $1 ( mode bits: 01 write stdin, 02 read stdout, 04 read stderr, 08 kill only )
28    |1f &exec $1 ( subprocess: run command )
29
30|0100
31    ;on-console .Console/vector DEO2
32    ;cmd .Console/addr DEO2
33    #02 .Console/mode DEO
34    #01 .Console/exec DEO
35    BRK
36
37( read output from pwd until first newline, then exit )
38@on-console
39    .Console/type DEI #01 EQU ?{ BRK }
40    .Console/read DEI DUP #0a EQU ?{ .Console/write DEO BRK }
41    .Console/write DEO
42    #80 .System/exit DEO BRK
43
44@cmd "pwd 00