exa
exa copied to clipboard
exa automatically expands softlinks when embedded in a pipe
Hi,
I found that exa would automatically expands softlinks when embedded in a pipe (I am using exa v0.9.0
on linux CentOS7
):
> ls | cat
raw_AAA.txt
raw_AAB.txt
sl_AAA.txt
sl_AAB.txt
> exa | cat
raw_AAA.txt
raw_AAB.txt
sl_AAA.txt -> raw_AAA.txt
sl_AAB.txt -> raw_AAB.txt
Which I think would cause unexpected problems, say if someone want's to rename all the softlink files through a pipe exa *.softlinks | while read file; do rename xxx yyy $file; done
, both the link file and the source file are renamed.
Best,
Songtao Gui
Can reproduce it on my machine
Environment:
$ uname -a
Linux pop-os 5.17.15-76051715-generic #202206141358~1655919116~22.04~1db9e34 SMP PREEMPT Wed Jun 22 19 x86_64 x86_64 x86_64 GNU/Linux
$ exa --version
exa - list files on the command-line
v0.10.1 [-git]
https://the.exa.website/
$ which $SHELL
/usr/bin/zsh
$ zsh --version
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
Test
$ exa -al
.rw-rw-r-- 0 steve 16 Jul 09:48 file1
lrwxrwxrwx 5 steve 16 Jul 09:49 file2 -> file1
$ ls|cat
file1
file2
$ exa|cat
file1
file2 -> file1
This is a little bit weird to me, normally redirection is implemented by the shell transparently. Thus the program being redirected shouldn't tell if it is redirected or not and should behave consistently in both cases.
Perhaps exa
has done something special to detect if its stdout
is a pipe
?
Related: Issues https://github.com/ogham/exa/issues/879 https://github.com/ogham/exa/issues/1083
Pull requests https://github.com/ogham/exa/pull/908? https://github.com/ogham/exa/pull/975
This is a little bit weird to me, normally redirection is implemented by the shell transparently. Thus the program being redirected shouldn't tell if it is redirected or not and should behave consistently in both cases. Perhaps exa has done something special to detect if its stdout is a pipe?
exa
detects the number of columns (the width) of the terminal.
Btw, ls
output also changes when it is piped:
$ ls
file1 file2
$ ls | cat
file1
file2