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

Ambiguity in piped vs not piped output #1046

Closed
stdedos opened this issue Jun 21, 2022 · 6 comments · Fixed by #1115
Closed

Ambiguity in piped vs not piped output #1046

stdedos opened this issue Jun 21, 2022 · 6 comments · Fixed by #1115
Labels

Comments

@stdedos
Copy link

stdedos commented Jun 21, 2022

What version of fd are you using?
[paste the output of fd --version here]

$ fd --version
fd 8.4.0

A short journey:

I am confused on why piped vs not piped output is different Hmmm... Do I have other `.editorconfig` files I can reference for my new one?
$ fd .editorconfig
$

WAT? 😕
(5 minutes) ... aaaah, okay, it's a hidden file, and hidden files are not searched by default:

$ fd -H .editorconfig
kNBcDyXJi/ecRlRPv/BXM_Je/.rPDclZxNgYyr
XFxiJagnA/WJgbrTD/OiInoDSAgiINUnkk/.YZmDuFuCckIL
WIHkZjomi/yIqdYhH/rfdDVKTAUBWSiXAo/GfaHm/lFbq/.xIRDWCIvevaM
fFXOXmAWN/acInlfx/flMaBjiDVIYVYtBI/RsoTY/BbzL/bFr#OkB/zbHTfZ/ifKaY/SfUIW]iXniUyQ/.UgrGwPaQeGmV
.EzjFK/eNeAOoJwm/omvRBNUvZ5263.2/WQSEH/qlBKQv=DShLzMF/OjqIhM.GfUVw.dnXazN.DLIpSSPOdtxn.bVkXV.Gywp/
.EHDIh/wRWiXKLRB/levauwvgX9517.2/JrmiW/YUOpol~LuqpgqS/TojFxD.qwYdl.JEjimx.rKtTUXgepXFs.ZOpma.eIJR/onSvQh.oONnz.gwLsWe.YBfzuemHHpvL.sDbfk.mmnj}XcmJiJ:O.CRL
.iWbGU/bhMyenPRx/ymTRQutnp7866.6/Thawj/dcogoa%tLTmpLj/DKkGys.eRRii.CIdXph.rUtUHfPNGwzu.hKAKv.tHbJ/XSvwvG.TtCRa.iKGOlp.tGqEddLfvCKy.yeJGp.XtEj|JdVAdBg.tjjLfvx.MPsrbBppO.XHi
.zsAeh/ZcXjHpZXA/vVaFyYjIa7460.9/FTgNJ/bsqXby%nlcvMKY/XGLlCa.CMfCh.uSXfFl.pEzyalOgKxvy.HXOTU.wXrm/[email protected]
.LSaEq/INMPskppO/JgHjUtlOA9796.6/YqmAQ/wYqCpj,smjcPsb/MYvWBa.LJBtO.yuBOck.xtrLwWIfdigW.LhCyW.xQeL/TGgeon.rkLRD.qWOrwe.YBlrzbPqxjyr.LMrTm.UIUR(DZYvpjy.ADvUPBO}m.ZiL
.awHQa/VLuNyKFhc/bplIgFZBx6563.2/rThOI/EgJjtJ{KCgOMWK/DZrPqH.LCMVE.lODdEt.CsUdpdhPGYgS.zXLfV.gRxy/drCbol.yIjmn.HjSjFq.LhpJOjRJTgrU.vsBXZ.YXzY.GbSJMNQ.klQFcFO.eqr
...
$ fd -H .editorconfig | wc -l
233
$

😵 ... but hey, if I look closer, there are paths that start with a dot (i.e. are hidden), and therefore "not mine". How about ...

$ fd -H .editorconfig | grep -vP '^\.'
$

WAT? 🤯

(15 minutes later) ...

$ fd -H .editorconfig | head
./kNBcDyXJi/ecRlRPv/BXM_Je/.rPDclZxNgYyr
./XFxiJagnA/WJgbrTD/OiInoDSAgiINUnkk/.YZmDuFuCckIL
./WIHkZjomi/yIqdYhH/rfdDVKTAUBWSiXAo/GfaHm/lFbq/.xIRDWCIvevaM
./fFXOXmAWN/acInlfx/flMaBjiDVIYVYtBI/RsoTY/BbzL/bFr#OkB/zbHTfZ/ifKaY/SfUIW]iXniUyQ/.UgrGwPaQeGmV
./.EzjFK/eNeAOoJwm/omvRBNUvZ5263.2/WQSEH/qlBKQv=DShLzMF/OjqIhM.GfUVw.dnXazN.DLIpSSPOdtxn.bVkXV.Gywp/
./.EHDIh/wRWiXKLRB/levauwvgX9517.2/JrmiW/YUOpol~LuqpgqS/TojFxD.qwYdl.JEjimx.rKtTUXgepXFs.ZOpma.eIJR/onSvQh.oONnz.gwLsWe.YBfzuemHHpvL.sDbfk.mmnj}XcmJiJ:O.CRL
./.iWbGU/bhMyenPRx/ymTRQutnp7866.6/Thawj/dcogoa%tLTmpLj/DKkGys.eRRii.CIdXph.rUtUHfPNGwzu.hKAKv.tHbJ/XSvwvG.TtCRa.iKGOlp.tGqEddLfvCKy.yeJGp.XtEj|JdVAdBg.tjjLfvx.MPsrbBppO.XHi
./.zsAeh/ZcXjHpZXA/vVaFyYjIa7460.9/FTgNJ/bsqXby%nlcvMKY/XGLlCa.CMfCh.uSXfFl.pEzyalOgKxvy.HXOTU.wXrm/[email protected]
./.LSaEq/INMPskppO/JgHjUtlOA9796.6/YqmAQ/wYqCpj,smjcPsb/MYvWBa.LJBtO.yuBOck.xtrLwWIfdigW.LhCyW.xQeL/TGgeon.rkLRD.qWOrwe.YBlrzbPqxjyr.LMrTm.UIUR(DZYvpjy.ADvUPBO}m.ZiL
./.awHQa/VLuNyKFhc/bplIgFZBx6563.2/rThOI/EgJjtJ{KCgOMWK/DZrPqH.LCMVE.lODdEt.CsUdpdhPGYgS.zXLfV.gRxy/drCbol.yIjmn.HjSjFq.LhpJOjRJTgrU.vsBXZ.YXzY.GbSJMNQ.klQFcFO.eqr
$

wat wat wat

I maybe get the reasoning behind this option, however, I think it's counter-intuitive (for me) to not be able to parse things the way I am seeing them (unless I specifically -print, -print0, etc ...).

Is there any way I can reconcile things for myself?

It seems that --strip-cwd-prefix helps me do what I want, but then it's annoying to remember to type that as well all the time (and then -H, and then sometimes --glob etc) ...
Is there a config file that I can use for this purpose (instead of an alias hidden somewhere)?

@tavianator
Copy link
Collaborator

Right, this was kind of discussed in #760, but not emphasized too much. I'm very sympathetic to this:

$ fd pattern
a/path/matching/pattern
$ fd pattern | grep '^a/path'
$ # ???

See #362 for previous discussion about a config file. Right now there isn't one. A shell alias might be the best alternative.

@sharkdp
Copy link
Owner

sharkdp commented Jul 11, 2022

Right, this was kind of discussed in #760, but not emphasized too much. I'm very sympathetic to this:

$ fd pattern
a/path/matching/pattern
$ fd pattern | grep '^a/path'
$ # ???

I also agree. This is not good. Do we want to change the behavior (again)? I'd hate to include the ./ part in the interactive output 🙁.

In the past, I have strictly argued against a config file for fd. And think I would still like to avoid it. But if we're talking about purely "cosmetical" things (e.g. color settings, precise shape of the interactive output), I might be convinced to re-think my position 😄.

@tavianator
Copy link
Collaborator

My preference would be to disable the ./ in piped output by default. It doesn't fully address the security issues anyway since newlines in paths are still an issue (./foo\n--dangerous-option). Most pipes are not to xargs IMO.

I would keep the leading ./ in -0 mode.

@sharkdp
Copy link
Owner

sharkdp commented Jul 17, 2022

That sounds like a very good idea. It would be (another) breaking change, but I think I'm also in favor of doing that.

FYI: @jcaplan @ykonstant1

@tavianator
Copy link
Collaborator

At least it's only breaking for one or two releases?

@tmccombs
Copy link
Collaborator

That seems ok to me too.

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

Successfully merging a pull request may close this issue.

4 participants