aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-02-25 07:30:05 -0500
committerB. Watson <urchlay@slackware.uk>2025-02-25 07:30:05 -0500
commit2da7ac8b7bd573d5cb24e83f4f308837630e9e78 (patch)
tree67b03121dbadb7b406f3774799a2786d74084230
parent1c075d559e69958af1964ad389393f496571d322 (diff)
downloadbw-atari8-tools-2da7ac8b7bd573d5cb24e83f4f308837630e9e78.tar.gz
listamsb: add -c (check only) option.
-rw-r--r--listamsb.114
-rw-r--r--listamsb.c17
-rw-r--r--listamsb.rst18
3 files changed, 44 insertions, 5 deletions
diff --git a/listamsb.1 b/listamsb.1
index 96e7dcb..37ece05 100644
--- a/listamsb.1
+++ b/listamsb.1
@@ -59,6 +59,10 @@ Output raw ATASCII. This option must be used with a pipe or redirection, as
\fBlistamsb\fP will not write ATASCII to a terminal. \fBa8cat\fP is not used,
with this option.
.TP
+.B \fB\-c\fP
+Check only. No output on stdout. Diagnostics are still printed on stderr,
+and the exit status is unchanged.
+.TP
.B \fB\-v\fP
Verbose output, on stderr.
.TP
@@ -67,8 +71,16 @@ Print built\-in help and exit.
.TP
.B \fB\-i\fP, \fB\-u\fP, \fB\-t\fP, \fB\-m\fP, \fB\-s\fP
These options are passed to \fBa8cat\fP\&. See its man page for details. If
-the \fB\-a\fP option is used, these options have no effect.
+the \fB\-a\fP or \fB\-c\fP option is used, these options have no effect.
.UNINDENT
+.SH DIAGNOSTICS
+.SH LIMITATIONS
+.sp
+Unlike \fBlistbas\fP, there\(aqs no color syntax highlighting. Probably there
+never will be.
+.sp
+It\(aqs hard to reliably detect AMSB files. If you feed \fBlistamsb\fP an
+Atari BASIC file, you\(aqll get gibberish output.
.SH EXIT STATUS
.sp
0 for success, 1 if there was an error reading the input (e.g. file
diff --git a/listamsb.c b/listamsb.c
index efa0621..5d9b425 100644
--- a/listamsb.c
+++ b/listamsb.c
@@ -34,8 +34,9 @@ const char *self;
char pipe_command[BUFSIZ + 1] = { "a8cat" };
-int verbose = 0;
-int raw_output = 0;
+int verbose = 0; /* -v */
+int raw_output = 0; /* -a */
+int check_only = 0; /* -c */
int need_pclose = 0;
int bytes_read = 0;
@@ -208,6 +209,7 @@ void print_help(void) {
puts("By B. Watson <urchlay@slackware.uk>, released under the WTFPL");
printf("Usage: %s [-a] [-v] [-h] [-i] [-u] [-t] [-m] [-s] [file]\n", self);
puts(" -a: raw ATASCII output");
+ puts(" -c: check only (no listing)");
puts(" -v: verbose");
puts(" -h: show this help");
puts(" -i -u -t -m -s: passed to a8cat (try 'a8cat -h')");
@@ -218,8 +220,9 @@ void parse_args(int argc, char **argv) {
char tmp[10];
int opt;
- while( (opt = getopt(argc, argv, "vaiutmsh")) != -1) {
+ while( (opt = getopt(argc, argv, "cvaiutmsh")) != -1) {
switch(opt) {
+ case 'c': check_only = 1; break;
case 'a': raw_output = 1; break;
case 'h': print_help(); exit(0);
case 'v': verbose = 1; break;
@@ -257,6 +260,14 @@ void parse_args(int argc, char **argv) {
}
void open_output() {
+ if(check_only) {
+ outfile = freopen("/dev/null", "wb", stdout);
+ if(!outfile) {
+ fprintf(stderr, "%s: ", self);
+ perror("/dev/null");
+ exit(1);
+ }
+ }
if(raw_output) {
if(isatty(fileno(stdout)))
die("refusing to write raw ATASCII to a terminal");
diff --git a/listamsb.rst b/listamsb.rst
index e6e2225..af72e73 100644
--- a/listamsb.rst
+++ b/listamsb.rst
@@ -41,6 +41,10 @@ OPTIONS
**listamsb** will not write ATASCII to a terminal. **a8cat** is not used,
with this option.
+**-c**
+ Check only. No output on stdout. Diagnostics are still printed on stderr,
+ and the exit status is unchanged.
+
**-v**
Verbose output, on stderr.
@@ -49,7 +53,19 @@ OPTIONS
**-i**\, **-u**\, **-t**\, **-m**\, **-s**
These options are passed to **a8cat**. See its man page for details. If
- the **-a** option is used, these options have no effect.
+ the **-a** or **-c** option is used, these options have no effect.
+
+DIAGNOSTICS
+===========
+
+LIMITATIONS
+===========
+
+Unlike **listbas**, there's no color syntax highlighting. Probably there
+never will be.
+
+It's hard to reliably detect AMSB files. If you feed **listamsb** an
+Atari BASIC file, you'll get gibberish output.
EXIT STATUS
===========