Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tweak the cli.

  • Loading branch information...
commit cadaf4f75570088b3c23730b216054f93634d0c0 1 parent b829b21
Gabriel de Perthuis authored

Showing 1 changed file with 14 additions and 9 deletions. Show diff stats Hide diff stats

  1. +14 9 enter-uml
23 enter-uml
@@ -5,15 +5,19 @@ import shutil
5 5 import sys
6 6 import urllib.parse
7 7
8   -script = sys.argv[0]
  8 +def path_resolve(cmd):
  9 + cmd0 = cmd
9 10
10   -if '/' not in script:
11   - script = shutil.which(script)
12   - assert script
  11 + if '/' not in cmd:
  12 + cmd = shutil.which(cmd)
  13 + assert cmd, cmd0
13 14
14   -script = os.path.abspath(script)
  15 + cmd = os.path.abspath(cmd)
  16 + assert os.path.exists(cmd), cmd0
  17 + return cmd
  18 +
  19 +script = path_resolve(sys.argv[0])
15 20
16   -assert os.path.exists(script)
17 21 assert script.endswith('/enter-uml')
18 22 runner = os.path.dirname(script) + '/uml-stub'
19 23 assert os.path.exists(runner)
@@ -34,8 +38,8 @@ parser = argparse.ArgumentParser()
34 38 preserve_default = 'HOME TERM PWD PATH SHELL'.split()
35 39
36 40 parser.add_argument(
37   - '--preserve-envvar', dest='preserve_envvars', nargs='*', default=[], metavar='ENVVAR')
38   -parser.add_argument('--kopt', dest='kopts', nargs='*', default=[], metavar='KOPT')
  41 + '--preserve-envvars', dest='preserve_envvars', nargs='*', default=[], metavar='ENVVAR')
  42 +parser.add_argument('--kopts', dest='kopts', nargs='*', default=[], metavar='KOPT')
39 43 parser.add_argument('--kernel', default='/usr/bin/linux.uml', metavar='EXECUTABLE')
40 44 parser.add_argument('--mem', default='128M')
41 45 parser.add_argument('cmd', nargs='*')
@@ -46,10 +50,11 @@ args = parser.parse_args()
46 50 preserve_envvars = preserve_default + [
47 51 var for var in args.preserve_envvars if var in os.environ]
48 52
49   -assert all('=' in kopt for kopt in args.kopts)
  53 +assert all('=' in kopt for kopt in args.kopts), args.kopts
50 54 assert all(map(kopt_safe, args.kopts))
51 55
52 56 cmd = args.cmd or [os.environ['SHELL']]
  57 +cmd[0] = path_resolve(cmd[0])
53 58
54 59 os.execvp(
55 60 args.kernel, [args.kernel]

0 comments on commit cadaf4f

Please sign in to comment.
Something went wrong with that request. Please try again.