[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Writing de/compressed data to a terminal policy
From: |
wrotycz |
Subject: |
Writing de/compressed data to a terminal policy |
Date: |
Sun, 02 Feb 2025 23:06:18 +0100 |
User-agent: |
GWP-Draft |
In windoze I got suprised by automatic terminal detection that forbade me to decompress to nul (like /dev/null equivalent, but not a regular file).
It could not be forced with -f/--force either, which I wanted to discuss/question.
So I started digging and figured out that it is because nul is not regular file in windows, therefore isatty detects it as terminal. But that is fine - as I explain below, it could be solved with forcing write with -f/--force.
I also and discovered that although lzip does not allow to compress to terminal but it does allow to decompress into terminal. Which is inconsistent, and not good in general imo.
It could be avoided if -f/--force would govern writing to terminal.
# Linux
~~~
$ echo Alice > a.txt
$ plzip -c a.txt
plzip: (stdout): I wont write compressed data to a terminal.
$ plzip -c a.txt > /dev/null
$ plzip -c a.txt > a.txt.lz
$ plzip -d -c a.txt.lz
Alice
$ plzip -d -c a.txt.lz > /dev/null
~~~
# Windoze
~~~
$ echo Alice > a.txt
$ plzip.exe -c a.txt
plzip: (stdout): I wont write compressed data to a terminal.
$ plzip.exe -c a.txt > nul
plzip: (stdout): I wont write compressed data to a terminal.
$ plzip.exe -c a.txt > a.txt.lz
$ plzip.exe -d -c a.txt.lz
Alice
$ plzip.exe -d -c a.txt.lz > nul
~~~
# gow me think it should look like
~~~
$ plzip -c a.txt
plzip: (stdout): I wont write compressed data to a terminal.
$ plzip -c a.txt > /dev/null
$ plzip -c a.txt > a.txt.lz
$ plzip -d -c a.txt.lz
plzip: (stdout): I wont write compressed data to a terminal.
$ plzip -d -c a.txt.lz > /dev/null
# plus what can be done about it
$ plzip -f -c a.txt
LZIP?? ¢ &F+ô=P¦ ¦ƒ@ *YS¦? *
$ plzip -f -d -c a.txt.lz
Alice
~~~
# and windows nul detection:
~~~
$ plzip.exe -f -c a.txt > nul
$ plzip.exe -f -d -c a.txt.lz > nul
~~~
Also tried to solve it on my own [1]. It is, obviously, partizan method, and you would make it lot better, I realise that, but it just shows how quickly do it and test the result.
Regards
- Writing de/compressed data to a terminal policy,
wrotycz <=