taviso / 123elf

A native port of Lotus 1-2-3 to Linux.
1.16k stars 59 forks source link

@INFO("osreturncode") isn't working #89

Open taviso opened 2 years ago

taviso commented 2 years ago

I think if you do this, the result should be 123:

123 -e '{system "exit 123"}@INFO("osreturncode")~'

It isn't, it's 31488 ... which is 123 << 8, so maybe it's the wrong endianness or something?

taviso commented 2 years ago

Ah, the bug is that UNIX system() returns the result, but Linux system() returns the wait status, and 1-2-3 doesn't know that.

Hmm, on the one hand It's easy to fix (just add WEXITSTATUS()), but should we fix it? Maybe it's more useful having all the wait() flags available?

Note: as a workaround you can do @INFO("osreturncode") / 2^8

OnesuchDev commented 1 year ago

Actually, SCO OpenServer returns the wait status too: http://osr507doc.sco.com/cgi-bin/man?mansearchword=/usr/man2/html.S/system.S.html&mansection= And Solaris: https://man.freebsd.org/cgi/man.cgi?query=system&apropos=0&sektion=0&manpath=SunOS+5.10&arch=default&format=html So this likely behaved the same even on a supported OS.

FWIW, Windows returns the exit code; I haven't developed anything for DOS but perhaps DOS C libraries do as well.