static gboolean parse(const char **input, ExArg *arg);
static gboolean parse_count(const char **input, ExArg *arg);
static gboolean parse_command_name(const char **input, ExArg *arg);
+static gboolean parse_bang(const char **input, ExArg *arg);
static gboolean parse_lhs(const char **input, ExArg *arg);
static gboolean parse_rhs(const char **input, ExArg *arg);
static void skip_whitespace(const char **input);
/* get the command and it's flags to decide what to parse */
cmd = &(commands[arg->idx]);
+ /* parse the bang if this is allowed */
+ if (cmd->flags & EX_FLAG_BANG) {
+ parse_bang(input, arg);
+ }
+
/* parse the lhs if this is available */
skip_whitespace(input);
if (cmd->flags & EX_FLAG_LHS) {
}
}
(*input)++;
- } while (matches > 0 && **input && **input != ' ');
+ } while (matches > 0 && **input && **input != ' ' && **input != '!');
if (!matches) {
/* TODO show readable error message */
return true;
}
+/**
+ * Parse a single bang ! after the command.
+ */
+static gboolean parse_bang(const char **input, ExArg *arg)
+{
+ if (*input && **input == '!') {
+ arg->bang = true;
+ (*input)++;
+ }
+ return true;
+}
+
/**
* Parse a single word left hand side of a command arg.
*/