aboutsummaryrefslogtreecommitdiff
path: root/a8cat.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-01 18:03:27 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-01 18:03:27 -0400
commit2926604dc6651711ab525ab5fd84762748ce51ff (patch)
tree5fdbbbcc751a7eee25e5a0ddac1b3568a7525031 /a8cat.c
parent77bdfd18057d87d3af870a6099865d8fa8bb980a (diff)
downloadbw-atari8-tools-2926604dc6651711ab525ab5fd84762748ce51ff.tar.gz
a8cat: refuse to write ATASCII to a terminal; swallow \r in -r mode.
Diffstat (limited to 'a8cat.c')
-rw-r--r--a8cat.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/a8cat.c b/a8cat.c
index e4a88bb..76ec67a 100644
--- a/a8cat.c
+++ b/a8cat.c
@@ -94,6 +94,8 @@ int a8revcat(const char *file) {
while( (c = fgetwc(input)) != WEOF ) {
if(c == 0x1b) {
inv = handle_escape_seq(inv, input, file, line);
+ } else if(c == '\r') {
+ continue; /* swallow carriage returns */
} else if(c == '\n') {
putchar(0x9b);
line++;
@@ -254,6 +256,9 @@ int main(int argc, char **argv) {
}
if(reverse) {
+ if(isatty(fileno(stdout)))
+ die("Refusing to write ATASCII to a terminal.");
+
if(underline || textmode || stripinv || magazine) {
die("-t, -u, -m, -s options don't make sense with -r.\n");
}