Live data from Hacker News

Using ChatGPT to make Bash palatable

brev.dev

51–60 of 148 posts

Re: Using ChatGPT to make Bash palatable

#51

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.

[deleted]

Re: Using ChatGPT to make Bash palatable

#52
post #46

Earlier quoted context omitted.

You've… really got the right answers from it? I've only ever asked it a couple of really basic (non-trick! straightforward!) questions about how to accomplish tasks by programming, but it bullshitted me some very plausible nonsense. Once bitten, twice shy. If it were capable of saying "I can't answer that question" reliably (which I've spent some time trying and failing to make it do, in general), it might actually b…

It happened to me once, it generates a plausible answer when it doesn't know (tried to generate a Nix script with Erlang). But I have used it to generate examples code in Haskell, and it was quite good, probably because Haskell libraries have excellent online documentation. It's much faster than reading the doc of the library.

When it generates bullshit answers just call him out and it will try another way to do it. Tell it specifically what doesn't make sense and it will fix it.

Re: Using ChatGPT to make Bash palatable

#54
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?

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

Re: Using ChatGPT to make Bash palatable

#55

Just today I used ChatGPT to help me speed up writing somewhat trivial C Code for a project in an embedded systems class. Prompt: "Generate a tiny PID controller with only a Proportional factor written in C. That takes a rotational input from -360 to 360 degrees. The setpoint in degrees. And returns a motor speed in the range of -255 to 255." => Produced a compiling correct result. Later I wanted to know how to commu…

I guess the main concern with its use as a learning tool is what happens if it's wrong? It might be helpful for boilerplate when you already know what you want, but if you don't even know that it'll blow up in your face when it doesn't give you something workable. Still, seems like a viable assistant so long as you have an understanding of what you're working with.

It's basically an augmenting tool. Can't rely on it 100% without a check, can't just do it without a vague idea of what the code does. As a combined boilerplate + search assistant it takes crazy amounts of work away as long as your specs are well defined, though.

Re: Using ChatGPT to make Bash palatable

#59
Am I the only who think this is incredible!?

If you would've told me a year ago when we would have an ai that can code based on normal human language prompts, I would've said maybe in 2025 or 2026, but its 2022 and it already exists!

Man, if this what we have now, imagine what we will have in 2025 or 2030!

I just hope this doesn't end up killing search engines and personal blogs, since no one needs to search for anything anymore.

Also Ai generated replys are definitely an Extinction level threat for forums and the independent internet in general, let's hope OpenAI can find a way to make chatgpt replies easy to filter out.

Re: Using ChatGPT to make Bash palatable

#60
post #8

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

Here is an example of where I think it is doing "no reasoning". I ask it for the XOR swap trick and I get: int a = 5; int b = 10; a = a ^ b; b = a ^ b; a = a ^ b; // After the swap, a = 10 and b = 5 I ask for the bitwise OR swap trick and I get: int x = 5; int y = 10; x = x | y; y = x | y; x = x | y; // After the swap, x = 10 and y = 5 When asked for something which is invalid, but close to something it knows, it ten…

Which is why prompt engineering is an emerging domain:

You will be given a series of tasks.

(1) Complete a task by finishing the simple code block.

(2) If a task in the series seems flawed, provide a warning. A task is flawed if I make wrong assumptions about how I think code works.

Task 1:

Complete this simple code example.

Bitwise XOR swap trick:

```

int a = 5;

int b = 10;

---------------------

    // GPT provides simple intro

    ```
    a = a ^ b;
    b = a ^ b;
    a = a ^ b;
    ```

    // GPT explains what this does, provides warnings about when it wont work

    // GPT provides full code
Task 2:

Complete this simple code example.

Bitwise OR swap trick:

```

int a = 5;

int b = 10;

---------------------

    There is no "bitwise OR swap trick" in programming. The OR operator (|) 
    performs a bitwise OR operation, which compares each bit of the first operand 
    to the corresponding bit of the second operand and returns a result with a 1 
    in each bit position where either operand has a 1. It does not have any built- 
    in ability to swap the values of two variables.
    // GPT provide a bunch of crap, and explains how to swap variables.

The prompt/alignment wasn't perfect here, but hopefully you get the point.

EDIT: sorry, format, Also copied wrong prompt.

Post reply on HN