[packages/adapter: 454/631] - use less only if terminal is to short
glen
glen at pld-linux.org
Mon Sep 12 20:12:30 CEST 2016
commit 38b4cf490ede5ec640fbd21da4d315070eabe9ff
Author: sparky <sparky at pld-linux.org>
Date: Tue Dec 1 02:39:43 2009 +0000
- use less only if terminal is to short
Changed files:
adapter.sh -> 1.40
adapter.sh | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/adapter.sh b/adapter.sh
index e497e65..3e1d324 100644
--- a/adapter.sh
+++ b/adapter.sh
@@ -104,6 +104,17 @@ diffcol()
' "$@"
}
+showdiff()
+{
+ l=$(cat $1 | wc -l)
+ eval $(resize) # get terminal size
+ if [ $l -gt $LINES ]; then
+ diffcol $1 | less -r
+ else
+ diffcol $1
+ fi
+}
+
diff2hunks()
{
# diff2hunks orignally by dig
@@ -222,7 +233,7 @@ adapterize() {
elif [ "$(diff --brief $SPECFILE $tmp)" ]; then
diff -u $SPECFILE $tmp > $tmp.diff
if [ -t 1 ]; then
- diffcol $tmp.diff | less -r
+ showdiff $tmp.diff
while : ; do
echo -n "Accept? (Yes, No, Confirm each chunk)? "
read ans
@@ -235,7 +246,7 @@ adapterize() {
[cC]) # confirm each chunk
diff2hunks $tmp.diff
for t in $(ls $tmp-*.diff); do
- diffcol $t | less -r
+ showdiff $t
echo -n "Accept? (Yes, [N]o, Quit)? "
read ans
case "$ans" in
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/adapter.git/commitdiff/6ca0126d4d0c8c79feb7db10b0a0fade0f3b8885
More information about the pld-cvs-commit
mailing list