prezto icon indicating copy to clipboard operation
prezto copied to clipboard

general: Remove redundant usage of `cat`

Open indrajitr opened this issue 3 years ago • 4 comments

In general, the substitution ‘$(cat foo)’ may be replaced by the equivalent but faster ‘$(<foo)’.

indrajitr avatar Apr 30 '21 02:04 indrajitr

@belak any view?

indrajitr avatar May 01 '21 00:05 indrajitr

I held off on this one before because I wanted to test it myself - it might be a little while until I can do that

belak avatar May 01 '21 00:05 belak

This is an interesting PR, to be sure - I didn't know this was possible. It mostly makes sense, but it's not the direction my brain would go for these.

I like the change in modules/python/init.zsh - that's a fairly common convention when reading from files which I've seen in multiple places before.

I have no strong opinions on the heredocs - they work, as far as I can tell, they're solid, and will probably perform marginally better. However, if it was purely my decision, I probably wouldn't push for that replacement - it's a bit less readable and doesn't follow with common conventions (I've never seen that before - really neat that it works), especially as seen in other shells. That hasn't stopped us before, at least when there's a zsh convenience, but for me in this specific case it wouldn't be worth it.

I'm a fan of the replacement in modules/python/init.zsh, and if you feel strongly about the heredoc change or think it adds enough value, you're definitely welcome to merge it as-is.

belak avatar May 06 '21 16:05 belak

Yes, readability does take a hit, I admit. But Zsh "hieroglyphs" (with all esoteric single-character flags and switches) probably don't focus on readability anyway I guess :)

One probable reason we don't see this convention around is probably because of POSIX compliance. Besides, pure Zsh optimized interactive shell is a niche space.

I'll hold off merging this just yet. Let's see if this PR can evolve a bit.

indrajitr avatar May 06 '21 17:05 indrajitr