Skip to content

Commit

Permalink
Fixes #38
Browse files Browse the repository at this point in the history
Rejects lone hyphens with some suggestions for workarounds
  • Loading branch information
bbrk24 committed Nov 25, 2023
1 parent 6696153 commit 09f64f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ string parse_args(int argc, _In_reads_z_(argc) const char** argv, flags& f) {
continue;
}

if (argv[i][1] == '\0') {
cerr << "'-' by itself is not a valid flag.\nTo reference a file called '-', use './-' or '-- -'. To "
"read from stdin, pass no\nfilename at all."
<< endl;
exit(EX_USAGE);
}

flag_container::set_flag(argv[i], f);
} else {
if (filename != nullptr) {
Expand Down
10 changes: 10 additions & 0 deletions tests/cli/invalid_flags/index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -u

errors="$($TRILANGLE - 2>&1 1<&-)"
result=$?
set -e
test 0 -ne $result

test -n "$errors"

0 comments on commit 09f64f3

Please sign in to comment.