From 7abdfc9beb34966fecfe34d50c98ff5eddbd0bb2 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 13 Mar 2018 17:49:49 -0500 Subject: [PATCH] Make system(NULL) detect whether a command processor is available. Previously, it just ran an Execute shell call with NULL as the command-line pointer. The fix is to still call Execute, but with an empty string as the command line, and then check if the call gave an error. If running under plain GS/OS, this gives an error for an unknown system call, whereas both ORCA/APW and GNO shells will return with no error in this case. (Golden Gate doesn't implement the Execute shell call, so it also gives an error and will report no command processor available.) This fixes issue #25. --- stdlib.asm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/stdlib.asm b/stdlib.asm index 191b0fa..a509ae8 100644 --- a/stdlib.asm +++ b/stdlib.asm @@ -973,14 +973,28 @@ system start sta exComm pla sta exComm+2 - phy execute the command + ora exComm + sta empty + bne lb1 if calling system(NULL) + lda #empty use empty command string + sta exComm + lda #^empty + sta exComm+2 +lb1 phy execute the command phx plb Execute ex - rtl + ldy empty + bne ret if doing system(NULL) + tya + bcs ret error => no command processor + inc a (& vice versa) +ret rtl ex dc i'$8000' exComm ds 4 + +empty ds 2 end ****************************************************************