Live data from Hacker News

A shell colon does nothing. Use it anyway

refp.se

41–50 of 191 posts

Re: A shell colon does nothing. Use it anyway

#41
post #24

life is way too short to deal with this nightmare of a language and its 50000 footguns for anything longer than a 2 line script, especially in the age of LLMs. Just write a python/TS/any real language script instead. Bash is great for the command line, it should be limited to use there.

I find LLM's too fall into the trap of writing a bash script for a task that clearly needs to be implemented in an Actual Language with Real Data Structures. For example, ask an LLM to bring up a SQL server with some schema + data preload step, and it will write a profoundly long bash script to do that task, every time.

Try being on linux and using zsh, it constantly fucks up scripts. Having it run commands via SSH into a windows machine is even more a comedy of errors.

I have to put in every claude.md that the shell is zsh. It's reached the point of annoyance I might just go back to bash.

Re: A shell colon does nothing. Use it anyway

#42
post #33
post #28

Earlier quoted context omitted.

Bash scripts requires "set -eu" at minimum, when written by LLM or human. It's the only language terrible enough to make the default behavior ignore undefined variables, commands, and execution errors, and happily continue executing whatever was produced by me smashing my hands on the keyboard, until the end of the file, while returning an exit code of 0, claiming complete success.

“Only language” eh? I only have a passing familiarity or very distant memory so could be wrong but I’d say these are the same: Perl (needs use strict) Ancient VB/VBA/VB script Original PHP (no idea about modern) PowerShell Old Windows/DOS batch

Javascript

Re: A shell colon does nothing. Use it anyway

#43
I've read through all of the examples in the article & they all seem to serve to sole purpose of turning readable multiple line code into one-liners.

One-liners are a cool little artifact of early shell culture & are sometimes still useful today if they're short to avoid the readability problems of `/` when copy pasting a quick shell command to run, but they have no place in scripts.

None of this seems useful to me.

> if you are like me and prefer less typing (gotta go fast)

Yeah, no.

Re: A shell colon does nothing. Use it anyway

#45
post #34

> ( : The subshell execution parentheses and the colon are superfluous here, just: Redirections do not require a colon command to hang off of, and there is no need to fork a subshell to execute such a command. > ( : >> result.json ) && echo YES # is result.json writable? As a go-to idiom for a writability test, it gives me pause. If the file didn't exist, we created a zero-length one. That might be okay if we are goi…

They are NOT superflous, and all you need to prove it is `zsh` (but there are others that follow suit in similar fashions): zsh% echo "hello world" > data zsh% So, if you want something that "everyone can use" without going into details about the difference between commonly used shells.. you'd use the null-command. --- and given that we use the null-command, it _WILL_ behave different with or without subshell.. and a…

It’s very common that the most upvoted comment on a post is a mistaken correction. People seem to love comments seemingly proving that the post is wrong without actually checking anything. And once it has enough upvotes a big discussion may follow up with personal attacks on the author or other questionable comments, while the people trying to point out that the post actually is accurate get either buried under the critic storm or downvoted to oblivion because people just don’t like the truth. This happens in every controversial topic.

One of the reasons I stopped writing.

Re: A shell colon does nothing. Use it anyway

#46
post #33

Earlier quoted context omitted.

“Only language” eh? I only have a passing familiarity or very distant memory so could be wrong but I’d say these are the same: Perl (needs use strict) Ancient VB/VBA/VB script Original PHP (no idea about modern) PowerShell Old Windows/DOS batch

Javascript

DataFlex

Re: A shell colon does nothing. Use it anyway

#47

I've read through all of the examples in the article & they all seem to serve to sole purpose of turning readable multiple line code into one-liners. One-liners are a cool little artifact of early shell culture & are sometimes still useful today if they're short to avoid the readability problems of `/` when copy pasting a quick shell command to run, but they have no place in scripts. None of this seems useful to me.…

Bash scripts should only be used for quick and dirty tasks where brevity is a major benefit. Don’t pretend bash can be readable and maintainable. If you want that use another language that sacrifices brevity for clarity.

Re: A shell colon does nothing. Use it anyway

#49
post #45
post #34

Earlier quoted context omitted.

They are NOT superflous, and all you need to prove it is `zsh` (but there are others that follow suit in similar fashions): zsh% echo "hello world" > data zsh% So, if you want something that "everyone can use" without going into details about the difference between commonly used shells.. you'd use the null-command. --- and given that we use the null-command, it _WILL_ behave different with or without subshell.. and a…

It’s very common that the most upvoted comment on a post is a mistaken correction. People seem to love comments seemingly proving that the post is wrong without actually checking anything. And once it has enough upvotes a big discussion may follow up with personal attacks on the author or other questionable comments, while the people trying to point out that the post actually is accurate get either buried under the c…

I have never been in this situation before but I do agree with you, and honestly it feels very bad. I saw the comment when it was posted and, perhaps naively, thought "oh well, no one will care - its just another fluff comment".

Fast-forward to seeing that comment climb up the ranks, posted by a person who has 270x my karma, who seemingly gets upvotes by just.. writing things? no proof? no rationale? nothing?

Yeah, feels bad. I'm super happy so many are enjoying the article, and this situation can't take too much away from that, but man.. discouraging for sure.

Re: A shell colon does nothing. Use it anyway

#50

Prefer if x then :; else something; fi over if ! x; then something; fi Really? Colon is the appendix of the shell.

The "if !" syntax isn't available on old enough shells.

Probably not an issue for most people in 2026 -- you have to back pretty far for it to be missing. Technically, though, "if x; then :; else" is more portable.

Post reply on HN