lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.06k stars 425 forks source link

[Bug]: Incompatible behavior with `ls` with newlines #1072

Open NazarioJL opened 1 month ago

NazarioJL commented 1 month ago

Version

version

1.1.2

What OS are you seeing the problem on?

macOS

installation

cargo install lsd

term

xterm-256color

ls-colors

di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43

What happened?

When trying to count words using `wc` I am getting different output. 

Repro steps

mkdir temp
cd temp
touch {00..40}.tmp
lsd | wc
#       3      41     327
/bin/ls | wc
#       41      41     287

Expected output:
  41      41     287
Actual output:
  3      41     287

What expected?

The line count for output _should_ be consistent with `/bin/ls`

What else?

No response

GottZ commented 1 month ago

Same problem here. ls uses to not make assumptions about width if it encounters the output stream is not tty

/usr/bin/lsd /dev/disk/by-id/ata-* | sed '/-part[0-9]+$/d'

/dev/disk/by-id/ata-Hitachi_HDS5C3020ALA632_ML4230FA16WWYK  /dev/disk/by-id/ata-Samsung_SSD_860_EVO_250GB_S3YJNX0KC01186R        /dev/disk/by-id/ata-ST4000DM004-2CV104_ZFN105KW
/dev/disk/by-id/ata-INTENSO_DCFE07860C0B01299906-part1      /dev/disk/by-id/ata-Samsung_SSD_860_EVO_250GB_S3YJNX0KC01186R-part2  /dev/disk/by-id/ata-ST4000DM004-2CV104_ZFN105WY
/dev/disk/by-id/ata-INTENSO_DD8B07860C0B01299904-part1      /dev/disk/by-id/ata-Samsung_SSD_870_QVO_8TB_S5SSNF0W614899R          /dev/disk/by-id/ata-ST8000DM004-2CX188_ZCT0F2E7

/usr/bin/ls /dev/disk/by-id/ata-* | sed '/-part[0-9]+$/d'

/dev/disk/by-id/ata-Hitachi_HDS5C3020ALA632_ML4230FA16WWYK
/dev/disk/by-id/ata-INTENSO_DCFE07860C0B01299906
/dev/disk/by-id/ata-INTENSO_DD8B07860C0B01299904
/dev/disk/by-id/ata-Samsung_SSD_860_EVO_250GB_S3YJNX0KC01186R
/dev/disk/by-id/ata-Samsung_SSD_870_QVO_8TB_S5SSNF0W409834J
/dev/disk/by-id/ata-Samsung_SSD_870_QVO_8TB_S5SSNF0W614899R
/dev/disk/by-id/ata-ST4000DM004-2CV104_ZFN105KW
/dev/disk/by-id/ata-ST4000DM004-2CV104_ZFN105WY
/dev/disk/by-id/ata-ST8000DM004-2CX188_ZCT0F2E7
GottZ commented 1 month ago

same as #1052 I'd say