1
1
mirror of https://github.com/casey/just.git synced 2024-09-11 05:55:31 +03:00

🔥 Disallow names that start with '-' (#154)

This is done for two reasons:

1. Such names cannot be given on the command line, since clap will
intercept them and wrongly interpret them as flags.

2. The name '---' can conflict with yaml document delimiters. Kind of
speculative, but I was thinking that it would be nice to make sure that
'---' and '...' are illegal in a justfile, so that that one can be
included in a yaml document stream. Is this silly? I am really not sure.

This is backwards incompatible, but I don't think anyone will notice,
since names that start with '-' are likely to be rare.
This commit is contained in:
Casey Rodarmor 2017-02-10 20:15:25 -08:00 committed by GitHub
parent 763f5798be
commit b6b01bf6d4
2 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ NEWLINE = \n|\r\n
EQUALS = =
INTERPOLATION_START = {{
INTERPOLATION_END = }}
NAME = [a-zA-Z_-][a-zA-Z0-9_-]*
NAME = [a-zA-Z_][a-zA-Z0-9_-]*
PLUS = +
RAW_STRING = '[^'\r\n]*'
STRING = "[^"]*" # also processes \n \r \t \" \\ escapes

View File

@ -1530,7 +1530,7 @@ fn tokenize(text: &str) -> Result<Vec<Token>, CompileError> {
static ref EQUALS: Regex = token(r"=" );
static ref INTERPOLATION_END: Regex = token(r"[}][}]" );
static ref INTERPOLATION_START_TOKEN: Regex = token(r"[{][{]" );
static ref NAME: Regex = token(r"([a-zA-Z_-][a-zA-Z0-9_-]*)");
static ref NAME: Regex = token(r"([a-zA-Z_][a-zA-Z0-9_-]*)" );
static ref PLUS: Regex = token(r"[+]" );
static ref STRING: Regex = token("\"" );
static ref RAW_STRING: Regex = token(r#"'[^']*'"# );