Using Bash examples was a bad idea. Bash scripts are by-and-large hacky things written to solve a simple problem expediently. OpenAI's output code reflects this reality. Expecting OpenAI to write Bash code defensively is like expecting OpenAI to complete SMS messages with scientific english.