]> git.pld-linux.org Git - packages/adapter.git/commitdiff
- use less only if terminal is to short
authorsparky <sparky@pld-linux.org>
Tue, 1 Dec 2009 02:39:43 +0000 (02:39 +0000)
committersparky <sparky@pld-linux.org>
Tue, 1 Dec 2009 02:39:43 +0000 (02:39 +0000)
Changed files:
    adapter.sh -> 1.40

adapter.sh

index e497e65b93546de5b2285c3c6ceaef94e161ec90..3e1d3245b9d385453e40c942df020ff2b233f459 100644 (file)
@@ -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
This page took 0.092573 seconds and 4 git commands to generate.