Smart quotes and dashes are useful in prose, but typographic punctuation can break code and shell commands. Turn the substitutions off where you edit plain-text instructions.
Check the current app first
In apps that support macOS substitutions, open Edit › Substitutions and inspect Smart Quotes and Smart Dashes. Disable the relevant options for your code or command-writing workflow.
Editors may provide their own settings instead. If the Edit menu has no such entry, consult that editor rather than assuming a macOS checkbox controls everything it types.
Change the system preference if needed
Open System Settings › Keyboard › Text Input › Edit and inspect Use smart quotes and dashes. Changing the default affects supporting apps; it does not guarantee that every website or editor uses the same text engine.
The change also does not repair punctuation already present in a file. Inspect existing quotes and dashes before pasting a command or saving a configuration.
Verify with harmless text
Type straight quotes around a sample word and two hyphens in an empty document. Copy the result into a code editor and inspect it. Appearance alone is unreliable because similar glyphs can represent different characters.
If whole words are being changed as well, see autocorrect controls. For inserting intentional typographic symbols in prose, Character Viewer lets you choose them explicitly.
Source: Apple: replace text and punctuation.
TapNoise