Live data from Hacker News

Using ChatGPT to make Bash palatable

brev.dev

61–70 of 148 posts

Re: Using ChatGPT to make Bash palatable

#61

ChatGPT has been amazing for all kinds of programming-adjacent things, even in my line of work where I asked it for help modifying the config file for a selfhosted gitlab instance. > But [Bash] fucking sucks. Like, it’s truly awful to write [...] As an aside, considering how basic the shell script actually was, I think this is a great example of being so intimidated by something that you don't actually try and use it…

Bash isn't that bad... except there are 20 ways to do anything and 18 of them are wrong, but only 1% of online examples will use either of the two correct approaches and simply reading docs won't always clue you in about how the technique or syntax it's describing is actually subtly wrong and you should ~never use it.

Bash _itself_ (or any other shell) is very small. You're talking about the ecosystem (shell + other command line utilities).

Commands like awk, find, grep, sed, cut and so many others are not strictly part of the language. They're external tools commonly provided by the operating system or distribution. That's why there are so many inconsistencies between their options.

Here are the very few commands that actually are part of any modern shell: cd, printf, test, read, command. The control structures (if/elif/fi, while/do/done, for/do/done, case/esac) are also part of the shell, so is declaring functions and fd redirection. Some shells might do more (bash itself has a handful of other builtins, dash has fewer, ksh has different ones).

Stuff like find, mv, cp and dd are very uniform across implementations and often don't change much, but they are external tools nonetheless.

Once you internalize this distinction, and start to see these external commands like npm packages, scripting gets a lot easier.

Re: Using ChatGPT to make Bash palatable

#62
post #41

I was just commenting to a friend how annoying it is that macOS aliases can't add flags to executables like you can easily do in Windows shortcuts since, what? Windows 95? If you want to launch Chrome with flags through your dock/UI you have to compile an AppleScript to an .app. It's crazy.

I don't use osx but surely you can create aliases just like in Linux and BSD?

Bash aliases (or whatever shell you are using) work exactly the same.

Re: Using ChatGPT to make Bash palatable

#63

ChatGPT has been amazing for all kinds of programming-adjacent things, even in my line of work where I asked it for help modifying the config file for a selfhosted gitlab instance. > But [Bash] fucking sucks. Like, it’s truly awful to write [...] As an aside, considering how basic the shell script actually was, I think this is a great example of being so intimidated by something that you don't actually try and use it…

Bash isn't that bad... except there are 20 ways to do anything and 18 of them are wrong, but only 1% of online examples will use either of the two correct approaches and simply reading docs won't always clue you in about how the technique or syntax it's describing is actually subtly wrong and you should ~never use it.

I've always been sheepish about this, but bash is my favorite programming environment! Not really because of any language features as such, more it's terseness and simplicity. Another big draw for me is bash's ubiquity. All of this makes bash the ultimate glue layer. That said, if a bash script goes longer than ten lines long I'll usually rewrite in python.

Re: Using ChatGPT to make Bash palatable

#64
post #41

Earlier quoted context omitted.

I don't use osx but surely you can create aliases just like in Linux and BSD?

Nope. macOS aliases suck. It’s a binary unmodifiable file that can only point to a file, it can’t specify anything additional.

Is there a reason you can't add a script to your path and alias that?

    #!/usr/bin/env bash
    my-command --flag --another-flag $@

Re: Using ChatGPT to make Bash palatable

#67
post #8

I don't understand how people can look at this and still claim that it's not doing any "actual reasoning".

"actual reasoning" doesn't mean anything concrete, until you define what you are talking about it can't be the basis of a question you can meaningfully answer.

I think Deutsch in The Beginning of Infinity has a lot to say about this, but I find it really hard to reproduce and summarise. Chapter 7, "artificial creativity" addresses the subject at length, here's Deutsch's own summary of it:

> The field of artificial (general) intelligence has made no progress because there is an unsolved philosophical problem at its heart: we do not understand how creativity works. Once that has been solved, programming it will not be difficult. Even artificial evolution may not have been achieved yet, despite appearances. There the problem is that we do not understand the nature of the universality of the DNA replication system.

He describes personhood, people, as "creative, universal explainers". That's his dividing line between what a child can do, and what LLMs cannot do. We don't know how a child works, but we do know how LLMs work.

Re: Using ChatGPT to make Bash palatable

#69
post #38

The problem you describe is how to interface with Google chrome on osx using shell script. I fail to see a single bashism.

It loops through the rows of a file in the last example. But yeah, the main reason this works is that this is a trivial bash script. The main help you got is not having to read the chrome command line docs.

Re: Using ChatGPT to make Bash palatable

#70
post #8

I don't understand how people can look at this and still claim that it's not doing any "actual reasoning".

How does it "reason" though, I thought LLM just generated likely next words?

I'm no expert and don't have a proper answer.

But my hunches/experience is that `proper prompting + nature of code being logical` really showcases the power of whatever statistical distribution and alignment occurs during generation. Further, there must be major upstream efforts of high-quality training data curation + creation, an advanced training tricks like using a LLM's strong ability in one task area to support the training of an area it is weak in.

Post reply on HN