Set maxsplit=0 for :spawn and split manually.

Fixes #759.
This commit is contained in:
Florian Bruhin 2015-06-17 07:57:38 +02:00
parent b1334bcc22
commit 6dbdea0ee3
3 changed files with 19 additions and 8 deletions

View File

@ -56,6 +56,7 @@ Changed
- The `ui -> user-stylesheet` setting now also takes file paths relative to the config directory.
- The `content -> cookies-accept` setting now has new `no-3rdparty` (default) and `no-unknown-3rdparty` values to block third-party cookies. The `default` value got renamed to `all`.
- Improved startup time by reading the webpage history while qutebrowser is open.
- The way `:spawn` splits its commandline has been changed slightly to allow commands with flags.
Deprecated
~~~~~~~~~~

View File

@ -529,20 +529,24 @@ Preset the statusbar to some text.
[[spawn]]
=== spawn
Syntax: +:spawn [*--userscript*] [*--verbose*] [*--detach*] 'args' ['args' ...]+
Syntax: +:spawn [*--userscript*] [*--verbose*] [*--detach*] 'cmdline'+
Spawn a command in a shell.
Note the {url} variable which gets replaced by the current URL might be useful here.
==== positional arguments
* +'args'+: The commandline to execute.
* +'cmdline'+: The commandline to execute.
==== optional arguments
* +*-u*+, +*--userscript*+: Run the command as an userscript.
* +*-v*+, +*--verbose*+: Show notifications when the command started/exited.
* +*-d*+, +*--detach*+: Whether the command should be detached from qutebrowser.
==== note
* This command does not split arguments after the last argument and handles quotes literally.
* With this command, +;;+ is interpreted literally instead of splitting off a second command.
[[stop]]
=== stop
Stop loading in the current/[count]th tab.

View File

@ -21,6 +21,7 @@
import re
import os
import shlex
import posixpath
import functools
import xml.etree.ElementTree
@ -919,8 +920,9 @@ class CommandDispatcher:
finally:
self._tabbed_browser.setUpdatesEnabled(True)
@cmdutils.register(instance='command-dispatcher', scope='window')
def spawn(self, userscript=False, verbose=False, detach=False, *args):
@cmdutils.register(instance='command-dispatcher', scope='window',
maxsplit=0)
def spawn(self, cmdline, userscript=False, verbose=False, detach=False):
"""Spawn a command in a shell.
Note the {url} variable which gets replaced by the current URL might be
@ -930,11 +932,15 @@ class CommandDispatcher:
userscript: Run the command as an userscript.
verbose: Show notifications when the command started/exited.
detach: Whether the command should be detached from qutebrowser.
*args: The commandline to execute.
cmdline: The commandline to execute.
"""
log.procs.debug("Executing: {}, userscript={}".format(
args, userscript))
cmd, *args = args
try:
cmd, *args = shlex.split(cmdline)
except ValueError as e:
raise cmdexc.CommandError("Error while splitting command: "
"{}".format(e))
log.procs.debug("Executing {} with args {}, userscript={}".format(
cmd, args, userscript))
if userscript:
self.run_userscript(cmd, *args, verbose=verbose)
else: