aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 74cb73d..14ff4eb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,7 @@ enum Error {
DuplicateCategory(OsString),
BadPath(PathBuf),
EmptyOption,
+ InvalidLiteral(String),
}
impl fmt::Display for Error {
@@ -54,6 +55,8 @@ impl fmt::Display for Error {
write!(f, "failed to parse path: {:?}", p),
Error::EmptyOption =>
write!(f, "multi-option variable had an empty option"),
+ Error::InvalidLiteral(s) =>
+ write!(f, "literal option contains an inner quote-mark: {}", s),
}
}
}
@@ -100,13 +103,11 @@ impl DropIn {
return Ok(DropIn::OneOf(options))
}
- // TODO: investigate viability of supporting escape sequences
- if let Some(inner) = text.strip_prefix('"')
- .and_then(|s| s.strip_suffix('"'))
- {
- // REVIEW: investigate interactions of filenames that contain '"'
- if !inner.contains('"') {
- return Ok(DropIn::Literal(inner.to_string()));
+ if let Some(lit) = text.strip_prefix('"') {
+ if lit.contains('"') {
+ return Err(Error::InvalidLiteral(text.to_string()));
+ } else {
+ return Ok(DropIn::Literal(lit.to_string()));
}
}