From 2a8a329b8340a9a877542f2b6ee9cbf3528d9ae5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Dec 2015 01:08:41 +0000 Subject: [PATCH] Remove support for %arg{#}, can be added back if we got a use case It is very unlikely we need %arg{#} without needing a %sh anyway. --- README.asciidoc | 3 +-- src/command_manager.cc | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 4e80e35f..eb02201b 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -630,8 +630,7 @@ Supported types are: * `val`: value expansion, gives access to the environment variable available to the Shell expansion. The `kak_` prefix is not used there. * `arg`: argument expansion, gives access to the arguments of the current - command, the content can be a number, or `#` for the argument count, - or `@` for all arguments concatenated. + command, the content can be a number, or `@` for all arguments. for example you can display last search pattern with diff --git a/src/command_manager.cc b/src/command_manager.cc index cd711c87..d5ccdeb7 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -348,17 +348,14 @@ String expand_token(const Token& token, const Context& context, } case Token::Type::ArgExpand: { - if (content == "#") - return to_string(shell_context.params.size()); - else if (content == "@") - return join(shell_context.params, ' '); + auto& params = shell_context.params; + if (content == '@') + return join(params, ' '); const int arg = str_to_int(content)-1; if (arg < 0) throw runtime_error("invalid argument index"); - if (arg < shell_context.params.size()) - return shell_context.params[arg]; - return {}; + return arg < params.size() ? params[arg] : String{}; } case Token::Type::RawEval: return expand(content, context, shell_context);