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