mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-13 09:40:42 +01:00
batgrep: Add support for '--'
This commit is contained in:
parent
82ac5c4391
commit
33e0c168e0
@ -130,6 +130,9 @@ while shiftopt; do
|
||||
fi
|
||||
} ;;
|
||||
|
||||
# --
|
||||
--) getargs -a FILES; break ;;
|
||||
|
||||
# ???
|
||||
-*) {
|
||||
printc "%{RED}%s: unknown option '%s'%{CLEAR}\n" "$PROGRAM" "$OPT" 1>&2
|
||||
@ -137,17 +140,15 @@ while shiftopt; do
|
||||
} ;;
|
||||
|
||||
# Search
|
||||
*) {
|
||||
if [ -z "$PATTERN" ]; then
|
||||
PATTERN="$OPT"
|
||||
else
|
||||
FILES+=("$OPT")
|
||||
fi
|
||||
} ;;
|
||||
*) FILES+=("$OPT") ;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
# Use the first file as a pattern.
|
||||
PATTERN="${FILES[0]}"
|
||||
FILES=("${FILES[@]:1}")
|
||||
|
||||
if [[ -z "$PATTERN" ]]; then
|
||||
print_error "no pattern provided"
|
||||
exit 1
|
||||
@ -229,6 +230,7 @@ main() {
|
||||
"${RG_ARGS[@]}" \
|
||||
--context 0 \
|
||||
--sort path \
|
||||
-- \
|
||||
"$PATTERN" \
|
||||
"${FILES[@]}" \
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user