Closed masahif closed 11 years ago
"cat file.tar.snz | snzcat > file.tar"
works for me without your fix.
What OS and compiler do you use?
IMO, isatty() is broken on your platform.
What terminal do you use? for example
As far as I tested, Emacs EShell mode is a only terminal where isatty() doesn't work correctly.
I've checked it again and I think my patch is not also enough to fix.
I'm using gnome-terminal and iTerm on Mac10.8.3. Tested following on Mac10.8.3. and CentOS6.3, both returned same result.
$ ./snzip I won't write compressed data to a terminal. For help, type: 'snzip -h'.
$ ./snzip file.tar
$ cat file.tar.sz | ./snzip -dc >file.tar
$ cat file.tar.sz | ./snzip -dc | cat > file.tar
$ cat file.tar.sz | ./snzip -dc | less
$ cat file.tar.sz | ./snzip -dc I won't write compressed data to a terminal. For help, type: 'snzip -h'.
I'll accept your pull request by another reason.
I noticed that both gzip and bzip2 didn't complain when they wrote uncompressed data to stdout as follows.
$ echo foo bar baz > test.txt
$ cat test.txt | gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
$ gzip test.txt
$ cat test.txt.gz | gzip -d
foo bar baz
$ echo foo bar baz > test.txt
$ cat test.txt | bzip2
bzip2: I won't write compressed data to a terminal.
bzip2: For help, type: `bzip2 --help'.
$ bzip2 test.txt
$ cat test.txt.bz2 | bzip2 -d
foo bar baz
On the other hand,
$ echo foo bar baz > test.txt
$ cat test.txt | ./snzip # same behaviour with gzip and bzip2.
I won't write compressed data to a terminal.
For help, type: 'snzip -h'.
$ ./snzip test.txt
$ cat test.txt.sz | ./snzip -d # different behaviour!!!
I won't write compressed data to a terminal.
For help, type: 'snzip -h'.
Your patch fixes the difference. However the commit message "Following way didn't work and fix it" isn't proper. Could you change the message and push it to this pull request or, if necessary, make a new pull request? Otherwise, can I commit it by myself?
Yes, I'd point out like your comment. Sorry for my irrelevance explaining.
I've changed my first comment.
Behaviour of snzip is difference with other same kind command such as bzip2 or gzip.
When the command use with stdin, only snzip complain.