Simplify reassembling for the command

This commit is contained in:
pagedown 2022-02-06 19:24:02 +08:00
parent 73a197fcde
commit 8ae273ee3a
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -383,15 +383,12 @@ class Tab: # {{{
import shlex import shlex
with suppress(OSError): with suppress(OSError):
with open(old_exe) as f: with open(old_exe) as f:
cmd_rest = cmd[1:]
cmd = [kitty_exe(), '+hold']
if f.read(2) == '#!': if f.read(2) == '#!':
line = f.read(4096).splitlines()[0] line = f.read(4096).splitlines()[0]
cmd += shlex.split(line) + [old_exe] cmd[:0] = shlex.split(line)
else: else:
cmd += [resolved_shell(get_options())[0], old_exe] cmd[:0] = [resolved_shell(get_options())[0]]
if cmd_rest: cmd[:0] = [kitty_exe(), '+hold']
cmd += cmd_rest
fenv: Dict[str, str] = {} fenv: Dict[str, str] = {}
if env: if env:
fenv.update(env) fenv.update(env)