Live data from Hacker News

A shell colon does nothing. Use it anyway

refp.se

111–120 of 191 posts

Re: A shell colon does nothing. Use it anyway

#111

I always wanted to learn more about scripting. But today I am not as passionate as before because LLMs write working scripts most of the time. I am wondering if it is true for most programming techniques and quirks. Are we going to write code to solve low level problems? The other day there was a blog post about learning SIMD. I think in future "programmers" will just nag about the speed of the program and the coding…

I can see crafting line by line when I’m retired or for a personal project. It’s eventually going to be like the people now who still operate restored manual linotype machines. “Look here I have the last functioning one in the midwest. See how the plates work…”

That legitimately sounds like the dream. Maybe this is just the universe's way of giving us our train set?

Re: A shell colon does nothing. Use it anyway

#113
post #97

Articles like this are fun but they all come from posix shell syntax being fundamentally bad for scripting/programming. All the piping stuff is great, of course. And the overall ecosystem is great. But the interpretation of the script itself working by a series of string substitutions is a mechanism we wouldn't accept in a regular programming language. And there's no excuse for it really, except that shell syntax is…

Your `$foo` example confused me at first because I thought the backticks are part of the example.

Sorry, the backticks were merely meant to delimit the code.

Re: A shell colon does nothing. Use it anyway

#116

Articles like this are fun but they all come from posix shell syntax being fundamentally bad for scripting/programming. All the piping stuff is great, of course. And the overall ecosystem is great. But the interpretation of the script itself working by a series of string substitutions is a mechanism we wouldn't accept in a regular programming language. And there's no excuse for it really, except that shell syntax is…

I feel the need to push back on this perspective. Old doesn't imply arcane. It instead can (and does, in this case) mean that it won out over the course of decades against other less worthy alternatives. Although you can write "programs" in sh, the shell syntax was never meant to be anything like a systems or application programming language. It was meant to efficiently automate systems tasks. It is kind of like the…

There are plenty of alternative shells that don't suffer these problems. Posix syntax didn't win because it was better - it's the classic 'worse is better'.

> Old doesn't imply arcane.

Indeed so. For example, awk is about the same age but doesn't suffer the same problems.

> the shell syntax was never meant to be anything like a systems or application programming language

A programmable shell is not only like a programming language, it is a programming language. Systems tasks have some specialised requirements but, overall, scripting is programming. There is nothing in the problem domain that requires the posix string-substitution problems.

If fish or oil had existed back then, they would likely have won, since they are better.

Re: A shell colon does nothing. Use it anyway

#117

Articles like this are fun but they all come from posix shell syntax being fundamentally bad for scripting/programming. All the piping stuff is great, of course. And the overall ecosystem is great. But the interpretation of the script itself working by a series of string substitutions is a mechanism we wouldn't accept in a regular programming language. And there's no excuse for it really, except that shell syntax is…

I will immediately remove all the shell scripts on my system based on this comment alone. Posted from my phone since my system came crashing down.

Heh, I like that. We are indeed stuck with posix shell syntax; I didn't claim we weren't.

Re: A shell colon does nothing. Use it anyway

#118

I always wanted to learn more about scripting. But today I am not as passionate as before because LLMs write working scripts most of the time. I am wondering if it is true for most programming techniques and quirks. Are we going to write code to solve low level problems? The other day there was a blog post about learning SIMD. I think in future "programmers" will just nag about the speed of the program and the coding…

I still think that learning the shell environment makes a lot of sense these days. But mainly for interactive use. It's amazing the scripts your LLM can make you with, say, fd and fzf.

Re: A shell colon does nothing. Use it anyway

#119

I use the colon as EDITOR with Git when I want to do an interactive rebase combined with auto squash without having to edit the todo list. I have an alias[1] for that which I call a quick interactive rebase: riq = -c sequence.editor=: rebase --interactive [1]: https://github.com/fphilipe/dotfiles/blob/94f2ff70bade070694...

That seems unsafe. It assumes that the editor is started via a shell command, and not executed directly. But there is no actual binary /usr/bin/: but there is a /usr/bin/true; I would use that instead.

Re: A shell colon does nothing. Use it anyway

#120

I really hate bash because of its unreadable syntax, and this does not help it in any way. We have some large bash scripts in my company, ~10,000 LOC spread across multiple files, all sourcing each other and what not. It is truly hard to read bash, which means it is truly hard to maintain bash, which means that when the one person knowing the bash scripts in your company goes away, you're in for some "fun". My point…

Absolutely!

Your company likely started using bash before python was ubiquitous.

Post reply on HN