diff options
author | B. Watson <urchlay@slackware.uk> | 2024-05-24 14:54:23 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-05-24 14:54:23 -0400 |
commit | a095768910dde7a8581aa018eceef5f2f899d1fa (patch) | |
tree | b0f48bd796817d06c8358fb5dd6762ad4c0c36f7 | |
parent | 59de645bcbc02f4044a697bbcc3a2a2a8523975f (diff) | |
download | bw-atari8-tools-a095768910dde7a8581aa018eceef5f2f899d1fa.tar.gz |
unprotbas: fix exit status.
-rw-r--r-- | unprotbas.1 | 4 | ||||
-rw-r--r-- | unprotbas.c | 14 | ||||
-rw-r--r-- | unprotbas.rst | 4 |
3 files changed, 15 insertions, 7 deletions
diff --git a/unprotbas.1 b/unprotbas.1 index 4d381b2..6c82dc0 100644 --- a/unprotbas.1 +++ b/unprotbas.1 @@ -98,12 +98,16 @@ can be used with these. .TP .B 0 \fBinput\-file\fP was protected, unprotection was successful. +With \fB\-p\fP, \fB\-pc\fP, \fB\-pv\fP: \fBinput\-file\fP was not +protected, protection was successful. .TP .B 1 I/O error, or \fBinput\-file\fP isn\(aqt a valid BASIC program. .TP .B 2 \fBinput\-file\fP is already an unprotected BASIC program. +With \fB\-p\fP, \fB\-pc\fP, \fB\-pv\fP: \fBinput\-file\fP is already a +protected BASIC program. .UNINDENT .SH DETAILS .sp diff --git a/unprotbas.c b/unprotbas.c index 686b8c3..cfdcf75 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -231,8 +231,10 @@ void breakcode(void) { break; } else { offset = data[pos + 2]; - if(!offset) - die("program already was code-protected"); + if(!offset) { + fprintf(stderr, "%s: program already was code-protected.\n", self); + exit(2); + } oldpos = pos; pos += offset; } @@ -732,6 +734,7 @@ int main(int argc, char **argv) { } if(protect_vars) scramble_vars(); if(protect_code) breakcode(); + was_protected = 1; /* opposite sense for this one */ } else { if(readmap) { was_protected = !vntable_ok(); @@ -764,10 +767,7 @@ int main(int argc, char **argv) { if(checkonly) { if(verbose) fprintf(stderr, "Check-only mode; no output written.\n"); - if(was_protected) - return 0; - else - return 2; + return was_protected ? 0 : 2; } } @@ -777,5 +777,5 @@ int main(int argc, char **argv) { if(writemap) write_var_map(); - return 0; + return was_protected ? 0 : 2; } diff --git a/unprotbas.rst b/unprotbas.rst index 138b228..13c16a6 100644 --- a/unprotbas.rst +++ b/unprotbas.rst @@ -80,12 +80,16 @@ EXIT STATUS 0 **input-file** was protected, unprotection was successful. + With **-p**, **-pc**, **-pv**: **input-file** was not + protected, protection was successful. 1 I/O error, or **input-file** isn't a valid BASIC program. 2 **input-file** is already an unprotected BASIC program. + With **-p**, **-pc**, **-pv**: **input-file** is already a + protected BASIC program. DETAILS ======= |