mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-11-07 16:24:06 +01:00
Fix gnu stat flag
- fix gnu stat formatting option from %z to %Z - use read with a one second timeout instead of sleep, then quit if user responds with "q" (for testing, mostly) - call pager_exec on entr and bat line instead of main so that --clear works
This commit is contained in:
parent
4c09718a46
commit
57be774f88
@ -52,7 +52,7 @@ watcher_entr_watch() {
|
||||
ENTR_ARGS+=('-c')
|
||||
fi
|
||||
|
||||
entr "${ENTR_ARGS[@]}" \
|
||||
pager_exec entr "${ENTR_ARGS[@]}" \
|
||||
"$EXECUTABLE_BAT" "${BAT_ARGS[@]}" \
|
||||
--terminal-width="$OPT_TERMINAL_WIDTH" \
|
||||
--paging=never \
|
||||
@ -77,7 +77,7 @@ determine_stat_variant() {
|
||||
|
||||
local varient name cmd ts
|
||||
|
||||
for varient in "gnu -c %z" "bsd -f %m"; do
|
||||
for varient in "gnu -c %Z" "bsd -f %m"; do
|
||||
name="${varient%% *}" cmd="stat ${varient#* }"
|
||||
|
||||
# keep the results of the stash command
|
||||
@ -123,10 +123,11 @@ watcher_poll_watch() {
|
||||
clear
|
||||
fi
|
||||
|
||||
"$EXECUTABLE_BAT" "${BAT_ARGS[@]}" \
|
||||
pager_exec "$EXECUTABLE_BAT" "${BAT_ARGS[@]}" \
|
||||
--terminal-width="$OPT_TERMINAL_WIDTH" \
|
||||
--paging=never \
|
||||
"${files[@]}"
|
||||
|
||||
fi
|
||||
|
||||
local i=0
|
||||
@ -141,7 +142,13 @@ watcher_poll_watch() {
|
||||
((i++))
|
||||
done
|
||||
|
||||
sleep 1
|
||||
read -r -t 1 input
|
||||
|
||||
if [[ "$input" =~ [q|Q] ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
input=
|
||||
done
|
||||
|
||||
"${POLL_STAT_COMMAND[@]}" "$@"
|
||||
@ -256,5 +263,5 @@ main() {
|
||||
return $?
|
||||
}
|
||||
|
||||
pager_exec main
|
||||
main
|
||||
exit $?
|
||||
|
4
test/snapshot/batwatch/test_displayed.stdout.snapshot
Normal file
4
test/snapshot/batwatch/test_displayed.stdout.snapshot
Normal file
@ -0,0 +1,4 @@
|
||||
echo Hello, test world!
|
||||
if true; then
|
||||
! true
|
||||
fi
|
@ -22,11 +22,10 @@ test:help() {
|
||||
batwatch --help | grep -q 'Usage'
|
||||
}
|
||||
|
||||
test:watcher() {
|
||||
description "Test 'batwatch <file>'"
|
||||
fail "No longer fails silently due to incorrect flag to stat."
|
||||
test:displayed() {
|
||||
description "Test 'batwatch <file>': <file> should be displayed'"
|
||||
snapshot stdout
|
||||
|
||||
# Refactored to get here, but when it passes it will loop forever.
|
||||
|
||||
assert batwatch $0
|
||||
batwatch --no-clear --watcher poll file.sh <<< "q"
|
||||
batwatch --watcher poll file.sh <<< "q" | grep -q "Hello"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user