Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 15 additions and 10 deletions.
  1. +15 −10 enter-uml
View
25 enter-uml
@@ -5,15 +5,19 @@ import shutil
import sys
import urllib.parse
-script = sys.argv[0]
+def path_resolve(cmd):
+ cmd0 = cmd
-if '/' not in script:
- script = shutil.which(script)
- assert script
+ if '/' not in cmd:
+ cmd = shutil.which(cmd)
+ assert cmd, cmd0
-script = os.path.abspath(script)
+ cmd = os.path.abspath(cmd)
+ assert os.path.exists(cmd), cmd0
+ return cmd
+
+script = path_resolve(sys.argv[0])
-assert os.path.exists(script)
assert script.endswith('/enter-uml')
runner = os.path.dirname(script) + '/uml-stub'
assert os.path.exists(runner)
@@ -34,9 +38,9 @@ parser = argparse.ArgumentParser()
preserve_default = 'HOME TERM PWD PATH SHELL'.split()
parser.add_argument(
- '--preserve-envvar', dest='preserve_envvars', nargs='*', default=[])
-parser.add_argument('--kopt', dest='kopts', nargs='*', default=[])
-parser.add_argument('--kernel', default='/usr/bin/linux.uml')
+ '--preserve-envvars', dest='preserve_envvars', nargs='*', default=[], metavar='ENVVAR')
+parser.add_argument('--kopts', dest='kopts', nargs='*', default=[], metavar='KOPT')
+parser.add_argument('--kernel', default='/usr/bin/linux.uml', metavar='EXECUTABLE')
parser.add_argument('--mem', default='128M')
parser.add_argument('cmd', nargs='*')
@@ -46,10 +50,11 @@ args = parser.parse_args()
preserve_envvars = preserve_default + [
var for var in args.preserve_envvars if var in os.environ]
-assert all('=' in kopt for kopt in args.kopts)
+assert all('=' in kopt for kopt in args.kopts), args.kopts
assert all(map(kopt_safe, args.kopts))
cmd = args.cmd or [os.environ['SHELL']]
+cmd[0] = path_resolve(cmd[0])
os.execvp(
args.kernel, [args.kernel]

No commit comments for this range

Something went wrong with that request. Please try again.