[LinuxSIG] ChatGPT to write code [was: Re: bash_httpd.sh]
Ron / BCLUG
admin at bclug.ca
Sun Mar 3 00:14:24 PST 2024
Craig Miller wrote on 2024-03-02 14:04:
> I suspect that 'bash' is low on the list of programming languages, and
> that is why AI models fair so poorly.
I'm not so sure - that list of features implemented in the script went
beyond 99.9% of bash scripts I've ever encountered.
I've never, ever used `mkfifo`.
I virtually never see `trap` used - one is ten times more likely to see:
`sudo curl ... | bash`
I've seen ChatGPT use bash arrays too, which I always have to do a
refresher on before I can use them.
> This is my complaint. It looks like bash code, but it doesn't run. I
> followed the instructions, made it executable, and then tried to run,
> and I get this:
Like you said, that's a copy / paste issue. Easy to make - emailing code
isn't great, I'll admit.
> $ curl localhost:8080/
> curl: (52) Empty reply from server
>
> So I stand by what I said, AI isn't good at bash programming.
The only error ChatGPT made was failing to pipe the output to fifo -
trivially easy to fix, and a boo-boo anyone could overlook.
Also, the `trap` might be incorrectly placed, but I played around with
it, changed the location and the signals, couldn't get anything to work
in the 10 or so minutes I tried to get it working...
So - Craig had copy / paste error, easily fixed & ChatGPT had a full
script with missing pipe statements.
It's a tie, but ChatGPT did a lot of extra lifting.
> You want a job that won't fall prey to AI, use bash
Not a lot of jobs are primarily bash scripting.
And, for the few seconds it took to get a working bash http server,
using features most Linux users have never encountered, I'm not so sure
bash scripting knowledge is job security.
If there's 10 bash scripters on staff (there aren't), replace 9 of them
with a ChatGPT account and have the tenth person review the output.
As the kids say, "10x improvement".
My 2¢.
rb
More information about the LinuxSIG
mailing list