pcstat icon indicating copy to clipboard operation
pcstat copied to clipboard

json output failed for empty file

Open niyue opened this issue 8 months ago • 0 comments

It will be great if the empty file case can be handled when outputting json.

steps to reproduce this issue

❯ touch /tmp/test.txt # create an empty file

❯ pcstat /tmp/test.txt
+---------------+----------------+------------+-----------+---------+
| Name          | Size (bytes)   | Pages      | Cached    | Percent |
|---------------+----------------+------------+-----------+---------|
| /tmp/test.txt | 0              | 0          | 0         |     NaN |
+---------------+----------------+------------+-----------+---------+

❯ pcstat -json /tmp/test.txt
2025/04/21 13:50:33 JSON formatting failed: json: unsupported value: NaN

niyue avatar Apr 21 '25 05:04 niyue