Live data from Hacker News

Using ChatGPT to make Bash palatable

brev.dev

111–120 of 148 posts

Re: Using ChatGPT to make Bash palatable

#111

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 is almost the same as stackoverflow. I've seen many answers which is runnable but without proper error handling or security mitigations. They are just as misleading as ChatGPT.

Re: Using ChatGPT to make Bash palatable

#112
On the other hand I’ve had vastly different experience.

Every single time I went to GPT and ask for anything development related I came back empty handed after being send for the goose chase.

An example of this would be when I asked fswatch to emit one faux event preemptively and it insisted to use “-1” instead (which quits after one event).

I had few instances for more obscure problems where GPT would actually create something I’d call parallel universe of the API. It felt good but such API never existed. Those problems were in JS, Ruby, Shellscript and Elixir.

One of the worst answer I was given was actually really buggy implementation of input controlled debounce function. It seemed correct when running but in reality it wasn’t debouncing but ignoring the output on debounce call.

So yeah, I don’t think I’ll be using GPT for that soon, but it works quite well as a rubber duck equivalent. By proposing dumb solutions I gather my thoughts better. Not sure if that’s something I’d pay for (yet I’d pay for text generating capabilities)

Edit: denounce -> debounce, because autocorrect

Re: Using ChatGPT to make Bash palatable

#114

Earlier quoted context omitted.

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…

Has anyone tried to make ChatGPT output first order logic statements about it's input problem, then make implications using a solver, then feed the solution back to ChatGPT for usage ? Maybe this could solve the reasoning part. ChatGPT should perform well in translating prompts to statement and vice versa, it's just text to text.

Precisely. This is stuff I’m actively working on. Feel free to reach out if you are curious.

Re: Using ChatGPT to make Bash palatable

#115

I find it interesting how much harder it is to grok bash/sh/zsh than other languages I’ve learned. Off the top of my head it may be tooling like the lack of linting, or maybe it’s just experience as I avoid complexity like the plague when writing bash which sounds like a self fulfilling feedback loop. Gpt does seem to unblock this mental burden a bit which has me excited for its potential when it comes to education/t…

Something about the quoting / unquoting can get really difficult to reason about. I'm rarely exactly sure how the language constructs work, even the for loop and the if statement. The syntax is complex compared to most other languages, and subtle differences can give totally different results. PICK = can you THE=tell the RIGHT=difference\ between WHAY="all of" TODO='these versions?'

It’s easy to reason. It’s a shell that takes commands first and not designed programming language.

I have no idea what 1st would evaluate (guess is that PICK is empty and can is run with you as an arg with PICK as execution context)

Second - simple. Run the with THE=tell as execution context.

Third - set variable to string containing space using backslash as escape

Fourth - set variable to string with interpolation (but also useful when it contains quotes)

Fifth - set variable to string sans interpolation (but also could be used to wrap strings with double quotes)

There are (at least) 2 rationales for that. First - shell have execution context. You need to be able to set it on command so syntax has to allow this. Dedicated programming languages ignore that because everything is some form of a block.

The other thing is actually quite fun. Shell existed before we used displays, so you could have printer connected to input. Imagine creating variable and then getting to “oh boy I need to add white space char” without possibility to do backspace. Escaping was more viable solution.

On top of that there are many shells with different APIs. Scripting languages were made so one could work with shell while having stable API and sensible construct units. Sure they either moved forward (like Python) or slipped into oblivion (like Perl), so it’s back for shell scripting for some.

But after doing some stuff with AppleScript lately I think it could be worse.

Re: Using ChatGPT to make Bash palatable

#116

Earlier quoted context omitted.

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 is almost the same as stackoverflow. I've seen many answers which is runnable but without proper error handling or security mitigations. They are just as misleading as ChatGPT.

Umm, no. I haven't seen answers there where people just invent non-existing options like ChatGPT does.

Re: Using ChatGPT to make Bash palatable

#117

Earlier quoted context omitted.

People like shell scripts because you have one interface: text For example: you need to write an image to a USB stick. Python: pretty lengthy BASH: image > /dev/SDA Both will do exactly the same, but one is a few lines of python the other just one line in bash.

Why a throwaway for this? Is this a gpt response? Also it's not right. You need to do something like image.img /dev/sda

    dd if= of= bs=
I use this whenever I need to bake an image to a USB stick.

Re: Using ChatGPT to make Bash palatable

#118

> But it fucking sucks. Like, it’s truly awful to write I feel like I'm the only person among my peers to think this and I don't understand why.

I had to try PowerShell for a project. It is soooo much better that bash. Passing typed objects instead of only text, Typed functions, and the ability to use C# types/functions inline !

Objects may be nice until they are not.

Personally, I'm of the opposite opinion.

I especially dislike the verbose syntax.

Re: Using ChatGPT to make Bash palatable

#119
post #82

Earlier quoted context omitted.

Something about the quoting / unquoting can get really difficult to reason about. I'm rarely exactly sure how the language constructs work, even the for loop and the if statement. The syntax is complex compared to most other languages, and subtle differences can give totally different results. PICK = can you THE=tell the RIGHT=difference\ between WHAY="all of" TODO='these versions?'

export YOU_FORGOT='this one' (Hint: it's most similar to your second one)

this has nothing to do with quoting

  also='another way to pass variables to child scopes' sh -c "echo $also"

Re: Using ChatGPT to make Bash palatable

#120
post #104
post #79

Earlier quoted context omitted.

This is a tool that I think openai originally made and seems to give you a probability that a sample block of text was or was not generated by openai. I pasted some of my own writing in there and said definitely not AI-generated. At this point, I don't know if I should be insulted by that or not. ;D https://huggingface.co/openai-detector

502 bad gateway. Followed a link to the wayback machine but that page didn't do anything.

Still works for me.
Post reply on HN