browser

cmdexec.xyw

cmdexec.xyw
calendarsave
.include "lib/macros.xyw"

; Set command to execute
cmd file.path STW
; Capture output to buffer
output file.read STW
$0100 file.length STW
; Execute command
file.op.exec file.operation STB
; Print OS based on output 
output linux contains JSRw print-linux JCNw
output bsd contains JSRw print-bsd JCNw
output darwin contains JSRw print-macos JCNw
output mingw contains JSRw print-windows JCNw
output windows contains JSRw print-windows JCNw
unknown puts JSRw NL
.label halt
HLT

.label print-windows
  windows puts JSRw NL
  halt JMPw

.label print-linux 
  linux puts JSRw NL
  halt JMPw

.label print-bsd 
  bsd puts JSRw NL
  halt JMPw

.label print-macos 
  macos puts JSRw NL
  halt JMPw
  
.include "lib/puts.xyw"
.include "lib/contains.xyw"

.label output
.reserve $0100
.label cmd
.string "uname -s"
.label linux
.string "Linux"
.label bsd
.string "BSD"
.label darwin
.string "Darwin"
.label mingw
.string "MinGW"
.label windows
.string "Windows"
.label macos 
.string "macOS"
.label unknown 
.string "Unknown"