Skip to content

Instantly share code, notes, and snippets.

@weaming
Created April 24, 2019 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaming/80d0be5e5e2db5790a6d7fe31a930bf0 to your computer and use it in GitHub Desktop.
Save weaming/80d0be5e5e2db5790a6d7fe31a930bf0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# coding: utf-8
"""
Author : weaming
Created Time : 2019-04-24 12:41:48
"""
import subprocess
import sys
import os
def run_shell(command):
return subprocess.run([os.getenv("SHELL") or "bash", "-c", command]).returncode
def read_lines():
rv = []
for x in sys.stdin:
x = x.rstrip("\n")
x = x.lstrip("$ ")
if x == "DONE":
break
rv.append(x)
return rv
commands = "; ".join(read_lines())
sys.eixt(run_shell(commands))
@weaming
Copy link
Author

weaming commented Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment