Live data from Hacker News

A shell colon does nothing. Use it anyway

refp.se

101–110 of 191 posts

Re: A shell colon does nothing. Use it anyway

#101

This "hidden knowledge" is fun to read but pain to remember and use, especially when working with multi-platform environments // Switched from bash to plain python scripts for shell stuff everywhere several years ago, and never looked back into bash zoo anymore. Stable syntax across Win/Mac/Linux, no bash/zsh/msys2 obscure differences, normal errors and Clause writes scaffolds quick and flawless anyway

I find Python a terrible bash replacement.

Calling all the command line tools is cumbersome, the Python cloud APIs are verbose compared to the cli tools and often have very different concepts for how they interact with services.

But I agree that there is a need for a better bash and zsh is nice but not the upgrade that is needed

Re: A shell colon does nothing. Use it anyway

#102

What if there was a less cryptic way to have mandatory arguments, something harder to get wrong, like param( [parameter(mandatory)] $name ) "Hello, $name!" And then: $ ./script.ps1 Dave Hello, Dave! $ ./script.ps1 -name Dave Hello, Dave! $ ./script.ps1 cmdlet script.ps1 at command pipeline position 1 Supply values for the following parameters: name: Or non interactively: $ pwsh -nonint ./script.ps1 script.ps1: Cannot…

PowerShell is a bad choice for the system shell because it's too complex. I'm not trying to justify all the quirks of Unix Shell, but minimalism is a very important feature of such a tool. Another important feature of a tool like this is the ability to tolerate errors: I can't imagine a Linux today that would be able to even boot if the shell was extra pedantic about errors. A lot of mostly irrelevant things routinel…

> System shell, however, isn't meant for writing entire applications.

Programmable shells are, in fact, for programming. That posix shell syntax makes it impractical for meaningfully large scripts is something you just accept. And, realistically, it is something you have to accept.

Minimalism isn't why posix shell syntax is bad. For example, awk and jq are minimal but don't make the same mistakes.

Powershell was never designed to be your system shell (Windows doesn't really rely on one) but the main reason it can't be the shell is startup time, which rules it out of wrapper scripts. Its having lots of features might contribute to that but it's not the problem per se (being built on .net is the reason - that and startup time not really mattering on windows). Its lacking the syntax problems of posix shells is very much not a problem. Powershell's error handling is just fine, by the way.

The startup time of even pwsh is too slow to be usable in many scenarios.

PowerShell's not going to be the system shell on your *nix box but it wasn't designed to be. But your posix shell isn't the system shell because it's better. It's pretty much the ultimate expression of worse is better.

That's why there's an industry of alternatives without the faults, such as oil, elvish, fish, nushell. And why awk is so popular.

Re: A shell colon does nothing. Use it anyway

#103

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 fork lift of computing. It does it's job very well, is bad at doing anything else, yet no other kind of vehicle can do it's job nearly as efficiently.

Comparing the shell to C, Go, Rust, Python, or JavaScript is crazypants. It has a different job than those, so of course it will look and feel different!

Re: A shell colon does nothing. Use it anyway

#104
post #5

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.

It turns out that LLMs are really good at writing bash too. even perl! maybe we should rethink some of these lost bits because we no longer need to worry about the arcane parts.

I have some absolutely amazing bash scripts that I would never have contemplated making myself in bash. And they'd only have been somewhat better in python. Claude for the win!

Re: A shell colon does nothing. Use it anyway

#105
post #32
post #24

Earlier quoted context omitted.

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.

my experience as well. claude produces functional but over-engineered scripts fairly frequently with often very questionably useful safety checks, especially for powershell. a common tell of ai generated powershell is a script that has dedicated functions to check types, often via several methods, and happily prints the output of the checks to shell. i do not get why it does this but it often adds dozens of lines tha…

$ Hey, claude, I've figured out the powershell one-liner we need and I've pasted it below. Please insert it into the application.

...

I have analysed your idiomatic one-liner and propose adding the following 30 lines into the application Yes/Yes and always accept such idiocy/No

ESCAPE ESCAPE

/clear

I want to update my powershell skill so that it writes idiomatic pipelines and does not introduce idioms from other languages.

[PASTES overeagerness wording from Claude prompting best practices]

Re: A shell colon does nothing. Use it anyway

#106

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.

Re: A shell colon does nothing. Use it anyway

#107

Earlier quoted context omitted.

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.

I find that Claude does this much more than other models. GPT, for instance, knows I'm on Windows running PowerShell, and writes very idiomatic PowerShell. But maybe that's because I'm the sucker, and since PowerShell is more verbose it costs me more tokens than the terseness of Unix shells. Oh well.

Some models are better than others. But it's all fixable with a relatively small skill. Try PowerShell Windows Skill perhaps.

Re: A shell colon does nothing. Use it anyway

#109
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 assistant will eventually introduce SIMD to the source code.

It is a little sad but we have to go with the current if we want to survive.

Re: A shell colon does nothing. Use it anyway

#110

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…”
Post reply on HN