continue-custom/docs/docs/languages/bash.md
2023-11-12 16:08:56 +01:00

6.3 KiB
Raw Blame History

Bash

Bash is the #7 most popular language according to the 2023 Stack Overflow Developer Survey.

Benchmarks

✅ Bash is one of the 19 languages in the MultiPL-E benchmark

❌ Bash is not one of the 16 languages in the BabelCode / TP3 benchmark

❌ Bash is not one of the 13 languages in the MBXP / Multilingual HumanEval benchmark

❌ Bash is not one of the 5 languages in the HumanEval-X benchmark

Datasets

✅ Bash makes up 8.69 GB of The Stack dataset

✅ Bash makes up 3.01 GB of the CodeParrot dataset

❌ Bash is not included in the AlphaCode dataset

❌ Bash is not included in the CodeGen dataset

❌ Bash is not included in the PolyCoder dataset

Stack Overflow & GitHub presence

Bash has 154,693 tagged questions on Stack Overflow

Bash projects have had 866,313 PRs on GitHub since 2014

Bash projects have had 574,292 issues on GitHub since 2014

Bash projects have had 3,605,350 pushes on GitHub since 2014

Bash projects have had 2,121,149 stars on GitHub since 2014

Anecdotes from developers

u/[deleted]

chatgpt is very bad at bash. Every script that someone has posted here has had some really glaring errors, often data-destructive ones. In general for every single use-case of chatgpt (or any other generative model) unless you understand the correct output you should not trust it. You can use it to produce documents and reports or even scripts, but you should always read the output carefully and validate that what it says is correct.

u/RandomXUsr

I've tried getting it to write some code. Very little is useful. It still very much requires education and experience with the tools you use in order to get effective, clean, and efficient code. I had tried some python scripts, but you need to specify libraries and tools to be used, and it doesn't do that well. As it learns more, it may become better at this, but for now it's a neat toy without real world benefits

u/stepbroImstuck_in_SU

This is more general advice for using chatGPT for generating bash scripts. chatGPT is a powerful tool, but it has both general and bash/linux related weaknesses. Never run script you don’t understand. That is a hard pill to shallow when learning bash, but thankfully you can ask chatGPT to explain its reasoning. To be sure, open a new conversation and ask for explanation of part of the code there. You can also ask another instance for a general explanation of a new syntax or command, and then cross-check the original code. After seeing what chatGPT knows about an individual command, it doesn’t hurt to quicklycheck the man-page anyway. ChatGPT is prone for using “general” syntax and flags even when some command doesn’t exist. Lastly, commands can change through years and environments. Your man-pages tell you what version you have. It’s a good strategy to ask if any tools already exist for the task or are build in, before asking for a bash script. For example you could script dropping your ssh-key in a remote machines .ssh-dir and then appending it to the trusted-keys file (or in folder) - or you can just use the ssh commands build in add-key option. There are a lot of tools build in to your average linux installation, and your distros repos are full of even more lightweight, trustworthy tools (as long as you stick to the official repos). If you aren’t exactly sure how a script behaves or if the syntax is robust, create your own test environments. You can create virtual (or real) directory structures, quickly fill them with very small files and run the script without touching your actual data. Ask chatGPT for more information (and use above steps to understand what it says). Related to the last point, pay attention to especially these aspects of any script chatGPT spews back: hardcoded paths (or less strictly, any path that isn’t declared as a variable on the start of the script). If instead of a robust test environment, you just use a directory with subdirectories, hardcoded paths can escape that environment, connections outside your machine/local network: While I feel it is unlikely that chatGPT will compromise your system by opening an unsafe connection to unsafe address, the risk is worth mitigating. What if the first guy who got that address noticed it’s not used, and bought it to distribute malware, hoping chatGPT offers it again? But more likely problem is that you can rapidly pull a lot of data from the internet. It just opens up more doors to make a mess, modifying files in /etc, or your bootloader. You can cause all kinds of damage, including permanently disabling rights to modify the files to fix it (misconfigured privileges), making your system unbootable (fstab, grub), and just generally messing up your system. Back it up before any changes, read the man-pages twice, make small tests (and remember you usually need to reload systemd or reboot before changes take effect)