7 ms·
Thanks for the recommendation. In my case, GPT revolutionized the way I use bash. If you know what you want to accomplish, gone are the days of endlessly fiddli
by brunorsini 3y ago
Thanks for the recommendation. In my case, GPT revolutionized the way I use bash. If you know what you want to accomplish, gone are the days of endlessly fiddling around with syntax.
- steve1977 3y agoUntil the day when GPT hallucinates some nice (and confident) rm -rf equivalent for you ;)
- anjanb 3y agoIt shouldn't be too difficult to pipe chatgpt output to bard or something equivalent and ask for validation
- spion 3y agoYou can also (surprisingly) ask ChatGPT for validation. The part of the LLM that activates when solving problems is going to be different than the one that activates when reviewing.
- ykonstant 3y agoWhich is extremely easy to do; just a misplaced `mv` is enough. I can't believe people are relying on GPT for ad hoc destructive I/O.
- MonaroVXR 3y ago>Which is extremely easy to do; just a misplaced `mv` is enough. Or `chown -r` or was it.. `chown -R`
- pipes 3y agoI used chat gpt to explain what a complex line in a bash script was doing. Though to be fair if I'd spent a day in man pages and Google I'd probably have learned a lot more than just being given the answer. Which makes think in the long run gpt may result in worse programmers.
- rascul 3y agohttps://explainshell.com/ https://explainshell.com/ can help with that but isn't perfect.
- Ma8ee 3y agoIn the same way as Stack Overflow has resulted in worse programmers, at least in some senses. I don’t mean to bash on SO, it’s really valuable sometimes. But corporate culture (faster is always better) and a new breed of programmers that don’t really care, have left us with a big part of the profession that are unable to produce anything new, or solve any unique problems.
- swatcoder 3y agoAnd a generation before that, it was VB and (early) PHP programmers that earned that critique. It does feel like the proportions might be changing and the quality of software is trending downward, but I think you have it right that the risk of programmers being too "GPT-reliant" is the continuation of a long, intergenerational pattern.
- an_aparallel 3y agothis is one of my BIGGEST frustrations learning to program. i do...not...want....to go online to work out hooow to do something. I want a "manual" - written well...that i can study and find the write tools to use...which for example (Pythons docs...are not...at least for beginners) - i then want to use the tools in said manual....to create. With the syntax, and the words you've defined oh so well in said manual. But...as the language grows...we'll just have to live with this never happening :) this is something i get jealous of older programmers who grew up on old computers, with printed manuals...when languages were smaller, and the scope of programs were also smaller...and didnt require external libraries.
- ElectricalUnion 3y agoPrograms were smaller with less expectations on them. Users were few and forcily clustered near the computer system. Attackers were limited and computer security was physical access control security. Now, it is kinda expected that programs support "text" - non-lgc alphabets, context-sensitive collations, ligatures and cursive text, mixed bidirectional text, combining characters, input method support, locale-dependent string interpolation logic. And one doen't simply handle all of that, not without bolting something else in your program that is probably larger that your program. And that isn't even instants in time; those are much harder to handle correctly all the time.
- Analemma_ 3y agoHave you actually tried it? Because this comment seems pretty misplaced with the reality of what ChatGPT can accomplish. I also use it all the time for bash one-liners, and so far my experience has been "80% work correctly on the first try, 15% require minor adjustment to run, 5% require major adjustment to run" and so far none have ever done anything flagrantly wrong or destructive. It also doesn't just print a command with no context: it explains what each flag/step of the command is purportedly doing, which you can (and should!) use to double-check that what you're about to run makes sense. Which is more than I can say for a lot of SO answers!
- anjanb 3y agoI've used chatGPT(ver 4 through ChATGPT plus) for creating .bat files. Really easy ones, it can churn out quite well. A lil more complicated - it doesn't consider edge cases. Several cases require me to ask it to generate a golang program that gets called by the .bat file. Several times, I had to spend hours to get a .bat script working. Hopefully, it will get better in the future.
- swatcoder 3y agoTraditionally, the alternative wasn't "SO answers", which are indeed dangerous in their own way -- it was to develop, and then maintain, a comprehensive and fluent understanding of the tools suitable to your profession. GPT and SO can help you make a deadline today, and we all may use them now and then, but consistently relying on them steals essential opportunities for professional growth. A journeyman woodworker who just asked somebody else to perform all his tricky jigsaw cuts is going to have a hard time developing the muscle memory and intuitions that mark mastery of the craft.
- simonw 3y agoI'd rather get to AI-assisted mastery of many more different crafts than limit myself to achieving mastery of just one single thing.
- fragmede 3y agoA master carpenter that only uses hand tools is a master of their craft, and should be respected as such, but refusing to ever use power tools because of a moral objection to electricity would be seen as quite the eccentricity. Which, the Amish sell furniture, and it's really quite good, if niche, furniture.
- cactusfrog 3y agoIt’s really useful for learning. “Describe this complex bash command I found on stack overflow line-by-line”. Write a quiz question to make sure I understand it. Rate my response to this quiz question.
- arcanemachiner 3y ago> Write a quiz question to make sure I understand it. Rate my response to this quiz question. I like this idea. Definitely gonna steal it. I love that "extensions" can be implemented just by writing a couple extra words.
- dotancohen 3y agoThis is what I come to HN for. I'll see if ChatGPT could maybe generate some relevant Anki cards as well.
- arcanemachiner 3y agoThere's a big difference between "build this program for me" and "explain how this line of bash code works". I use LLMs for the latter, and they often do a great job and save a lot of time looking up individual flags, concepts, etc.
- Too 3y agoBoth could be equally wrong and hallucinated.
- thedaly 3y ago> Both could be equally wrong and hallucinated. As can I. I recently broke my years long streak of not deleting something by accident with an errant bash command. Just because a tool has the potential for a negative outcome doesn't mean it shouldn't be used. It just means appropriate caution should be used as well.
- williamcotton 3y agoThis statement implies that LLM hallucinations are completely random which is objectively false. LLMs fill in the blanks when left to synthesize a response from a prompt as opposed to translating a response from a prompt. These synthesized responses, aka hallucinations, are predictable in nature. Quotes, titles of books, web page links, etc. Conversely, providing an LLM with all of the facts necessary to complete a response will result in few to no hallucinations. For example: Select name and row_id from table1 joined on table2 on table1_id. This will never return "DROP table1;". It will basically only ever return something very close to what you want.
- williamcotton 3y agoWhy the downvotes? The comment is not rude and it is factually correct.
- Too 3y agoNot my downvotes but this is factually incorrect. A LLM will give you the highest likely suggestion. If that happens to be a DROP, it will not stop. Now that is of course going to be extremely unlikely in your example. What is more likely though is that your SELECT may include a sql injection vulnerability, even more so once your prompts get more complex. The chance of that happening or not, is completely random from a users point of view. Are we going to blame the user for not providing the requirement “without vulnerabilities”? Even if they did, it’s not sure to be fulfilled. In this parent case, the scenario was inverted. Given a sql query, will gpt explain if it has vulnerabilities or not? Will it even explain the gist of it correct? Who knows if it will hallucinate or not? As will answers from stackoverflow, always read the comments, always review yourself. Use gpt all you want. I do it it myself, it’s great for suggestions. Just think that using gpt to explain things you don’t understand and can’t verify easily, can be risky. Even more so in bash where the difference making a destructive command can be a lot more subtle than select vs drop.
- AlecSchueler 3y agoI haven't tried GPT for this purpose but I don't think we need to assume that everyone tinkering with it are blindly copy pasting potentially destructive commands. Anyone who does that now would already have done it from random Google results anyway.
- da39a3ee 3y agoNot used GPT much?
- Timpy 3y agoFor me bash is a weird exception to the rule "code is easier to write than it is read". I'm never doing anything crazy in a shell a script but it's easy to just ask ChatGPT to whip it up for me and I will read it to verify. Perhaps anybody who can't validate the output is just as likely to write an accidentally-destructive script the old fashioned way.
- tovej 3y agoGood luck with that, hope you never have to write a portable shell script
- markstos 3y agoThere's a method that's even faster than asking ChatGPT what to type, and that's knowing what to type. For tasks you do regularly, it's worth the investment to learn.
- kstrauser 3y agoI agree. Here it's being used like a translation app: convert English into the shell language. That's all well and good for a place you're going to visit a couple of times, but if you plan on living there, you need to learn the local language.
- AlecSchueler 3y agoBeing able to use a tool akin to Google translate is a fantastic boon to language learning though.
- kstrauser 3y agoAbsolutely! It’s a fantastic learning cool, but not a substitute for actual learning.
- _fizz_buzz_ 3y agoTrue, but we cannot possible learn all the things. I wrote a nice little batch script last week with the help of ChatGPT. This is something I have to do maybe once or twice a year and I am sure someone who does this every day was a lot faster, but what took me maybe 30 mins would've taken me a day.
- worik 3y agoYes. But there is so much to know one short life I use Perl, now, for shell scripts. Long before LLMs I decided I could not learn another syntax when Perl was 99% as good Same reason I have not learnt Sed and Awk.
- thrwlol 3y agoYou really should compare your typing speed with chatgpt if you think you can out type it for a question that you know. Once I write the document string of the function I want it gets it right faster than anyone I know.
- RichardCA 3y agoJust last week I was asked to provide some possible screening questions to recruit for a Devops role. I figured this would be good: "How do you pass a parameter to a Bash script so that the script will exit with an error if it's not passed?" I ran this through ChatGPT and I could not get it to give ${1:?} or any variation of that syntax as an answer. So now I also have a way to filter candidates who are leaning on the LLM during the interview process.
- zatkin 3y agoThanks for the tip, I now know that I can’t use ChatGPT when I’m being interviewed with this question.
- Karellen 3y agoIs this for an in-person interview? Because without checking `man` or stackoverflow (or leaning on ChatGTP) my first response would be to go with `if [ $# -lt 1 ]; ...`. This has the advantage of being pretty readable, and while I've been doing shell scripting for long enough to consider myself reasonably competent at it, I'd have to refer to the man page to be sure what `${1:?}` did.
- stracer 3y agoThat's an unwise way to filter out candidates. It's an obscure and unimportant syntax feature whose effect can be accomplished in many other, more readable ways. Writing line noise using obscure syntax is not a sign of a good programmer. If you want to find good candidates, give them an assignment in bash and make them explain their solution.
- simonw 3y agoI said "Give me the most succinct possible idiom" and it gave me the answer you were looking for: https://chat.openai.com/share/05a3d1aa-cd60-40a1-b6d5-ec0c9f63b1c0 https://chat.openai.com/share/05a3d1aa-cd60-40a1-b6d5-ec0c9f...
- mgdlbp 3y agoThe first answer is wrong, so is the second's explanation... twice it conflates unset with null/empty. Very illustrative! The substance of the first answer: #!/bin/bash # Check if the first parameter is not provided if [ -z "$1" ]; then echo "Error: Parameter not provided." exit 1 fi The snippet precedes the true statement: > This checks if the first parameter (`$1`) is empty. But what happened to the supplied task? It was stated and echoed as: > Anonymous: ...if it's not passed? > ChatGPT: ...if a specific parameter is not passed... > ChatGPT: ...if the parameter is set. The second answer: #!/bin/bash : ${1?"Error: Parameter not provided"} This is correct. But the explanation is not: > ...and the `${1?...}` part checks if the first positional parameter (`$1`) is unset or null. -- (the most succinct possible idiom is `#!/bin/bash -u`)
- deleted 3y ago[deleted]