Why do I have to type ctrl-d twice? [duplicate]
问题 This question already has answers here : Why do I have to press Ctrl+D twice to close stdin? (5 answers) Closed 5 years ago . For my own amusement, I've cooked up a python script that allows me to use python for bash one-liners; Supply a python generator expression; and the script iterates over it. Here's the script: DEFAULT_MODULES = ['os', 're', 'sys'] _g = {} for m in DEFAULT_MODULES: _g[m] = __import__(m) import sys sys.stdout.writelines(eval(sys.argv[1], _g)) And here's how you might use