Post History
I tried to think of some for a while, but couldn't find any good ones. That said, there's plenty of programs I don't know. For reference: $ echo -en "hello\nworld" | tee 1.txt | bat -A ───────┬──...
Answer
#3: Post edited
- I tried to think of some for a while, but couldn't find any good ones. That said, there's plenty of programs I don't know. For reference:
- ```
$ echo -en "helloworld" | tee 1.txt | batf -A- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world
- ───────┴─────────────────────────────────────────
$ echo -e "helloworld" | tee 2.txt | batf -A- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world␊
- ───────┴─────────────────────────────────────────
- ```
- * `wc` appears to count newlines, so `wc 1.txt` incorrectly returns 1 for line count (you've mentioned this already)
- * `sort` and `uniq` behave sensibly
- * Python `readlines()` returns a list where the last item doesn't have a line ending, but this wouldn't normally break anything since usually people call `strip()` on each line (or set `keepends=False`)
- It's hard to think of an example which is not contrived.
- From a programmer's perspective, when your program has some specific requirement for input, you would want to either detect it and fail, or automatically correct it. Both are quite easy for missing terminal newlines. Standards are nice, but when you have a few thousand users or more, you simply cannot assume that not a single one would flout them. I would be surprised if there are any real cases where this is a problem, but I'm curious to see what others will post.
- I do know one common case: It can mess up your shell prompt to print such files:
- ```
- $ bash
- $ cat 1.txt
- hello
- world$
- ```
- Of course, this is easily resolved by pressing `Enter` to get a new prompt. Note also how I had to open bash for this - my normal shell, fish, handles it:
- ```
- $ cat 1.txt
- hello
- world⏎
- $
- ```
- As does zsh:
- ```
- $ cat 1.txt
- hello
- world%
- $
- ```
- I tried to think of some for a while, but couldn't find any good ones. That said, there's plenty of programs I don't know. For reference:
- ```
- $ echo -en "hello
- world" | tee 1.txt | bat -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world
- ───────┴─────────────────────────────────────────
- $ echo -e "hello
- world" | tee 2.txt | bat -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world␊
- ───────┴─────────────────────────────────────────
- ```
- * `wc` appears to count newlines, so `wc 1.txt` incorrectly returns 1 for line count (you've mentioned this already)
- * `sort` and `uniq` behave sensibly
- * Python `readlines()` returns a list where the last item doesn't have a line ending, but this wouldn't normally break anything since usually people call `strip()` on each line (or set `keepends=False`)
- It's hard to think of an example which is not contrived.
- From a programmer's perspective, when your program has some specific requirement for input, you would want to either detect it and fail, or automatically correct it. Both are quite easy for missing terminal newlines. Standards are nice, but when you have a few thousand users or more, you simply cannot assume that not a single one would flout them. I would be surprised if there are any real cases where this is a problem, but I'm curious to see what others will post.
- I do know one common case: It can mess up your shell prompt to print such files:
- ```
- $ bash
- $ cat 1.txt
- hello
- world$
- ```
- Of course, this is easily resolved by pressing `Enter` to get a new prompt. Note also how I had to open bash for this - my normal shell, fish, handles it:
- ```
- $ cat 1.txt
- hello
- world⏎
- $
- ```
- As does zsh:
- ```
- $ cat 1.txt
- hello
- world%
- $
- ```
- And of course, `cat` behaves a bit surprisingly (well, not really):
- ```
- $ cat * | bat -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ worldhello␊
- 3 │ world␊
- ───────┴─────────────────────────────────────────
- ```
#2: Post edited
- I tried to think of some for a while, but couldn't find any good ones. That said, there's plenty of programs I don't know. For reference:
- ```
- $ echo -en "hello\nworld" | tee 1.txt | batf -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world
- ───────┴─────────────────────────────────────────
- $ echo -e "hello\nworld" | tee 2.txt | batf -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world␊
- ───────┴─────────────────────────────────────────
- ```
- * `wc` appears to count newlines, so `wc 1.txt` incorrectly returns 1 for line count (you've mentioned this already)
- * `sort` and `uniq` behave sensibly
- * Python `readlines()` returns a list where the last item doesn't have a line ending, but this wouldn't normally break anything since usually people call `strip()` on each line (or set `keepends=False`)
It's hard to think of an example which is not contrived.
- I tried to think of some for a while, but couldn't find any good ones. That said, there's plenty of programs I don't know. For reference:
- ```
- $ echo -en "hello\nworld" | tee 1.txt | batf -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world
- ───────┴─────────────────────────────────────────
- $ echo -e "hello\nworld" | tee 2.txt | batf -A
- ───────┬─────────────────────────────────────────
- │ STDIN
- │ Size: -
- ───────┼─────────────────────────────────────────
- 1 │ hello␊
- 2 │ world␊
- ───────┴─────────────────────────────────────────
- ```
- * `wc` appears to count newlines, so `wc 1.txt` incorrectly returns 1 for line count (you've mentioned this already)
- * `sort` and `uniq` behave sensibly
- * Python `readlines()` returns a list where the last item doesn't have a line ending, but this wouldn't normally break anything since usually people call `strip()` on each line (or set `keepends=False`)
- It's hard to think of an example which is not contrived.
- From a programmer's perspective, when your program has some specific requirement for input, you would want to either detect it and fail, or automatically correct it. Both are quite easy for missing terminal newlines. Standards are nice, but when you have a few thousand users or more, you simply cannot assume that not a single one would flout them. I would be surprised if there are any real cases where this is a problem, but I'm curious to see what others will post.
- I do know one common case: It can mess up your shell prompt to print such files:
- ```
- $ bash
- $ cat 1.txt
- hello
- world$
- ```
- Of course, this is easily resolved by pressing `Enter` to get a new prompt. Note also how I had to open bash for this - my normal shell, fish, handles it:
- ```
- $ cat 1.txt
- hello
- world⏎
- $
- ```
- As does zsh:
- ```
- $ cat 1.txt
- hello
- world%
- $
- ```
#1: Initial revision
I tried to think of some for a while, but couldn't find any good ones. That said, there's plenty of programs I don't know. For reference: ``` $ echo -en "hello\nworld" | tee 1.txt | batf -A ───────┬───────────────────────────────────────── │ STDIN │ Size: - ───────┼───────────────────────────────────────── 1 │ hello␊ 2 │ world ───────┴───────────────────────────────────────── $ echo -e "hello\nworld" | tee 2.txt | batf -A ───────┬───────────────────────────────────────── │ STDIN │ Size: - ───────┼───────────────────────────────────────── 1 │ hello␊ 2 │ world␊ ───────┴───────────────────────────────────────── ``` * `wc` appears to count newlines, so `wc 1.txt` incorrectly returns 1 for line count (you've mentioned this already) * `sort` and `uniq` behave sensibly * Python `readlines()` returns a list where the last item doesn't have a line ending, but this wouldn't normally break anything since usually people call `strip()` on each line (or set `keepends=False`) It's hard to think of an example which is not contrived.