Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exa automatically expands softlinks when embedded in a pipe #1079

Open
songtaogui opened this issue Jun 27, 2022 · 2 comments
Open

exa automatically expands softlinks when embedded in a pipe #1079

songtaogui opened this issue Jun 27, 2022 · 2 comments

Comments

@songtaogui
Copy link

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


@SteveLauC
Copy link

SteveLauC commented Jul 16, 2022

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?

@t-gebauer
Copy link

Related:
Issues #879 #1083

Pull requests #908? #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants