comparison bin/ix.sh @ 90:5384208a0834

-w and -h working
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 14 Apr 2021 08:57:43 +0000
parents 90f8f28b2e51
children 82c94684f799
comparison
equal deleted inserted replaced
89:90f8f28b2e51 90:5384208a0834
33 while { IFS=$'\t' read f l o; } 33 while { IFS=$'\t' read f l o; }
34 do 34 do
35 dd if="$f" of=/dev/stdout skip=$o count=$l \ 35 dd if="$f" of=/dev/stdout skip=$o count=$l \
36 iflag=skip_bytes,count_bytes 2>/dev/null 36 iflag=skip_bytes,count_bytes 2>/dev/null
37 done | unpigz -dp 1 -c | \ 37 done | unpigz -dp 1 -c | \
38 s="w" 38 { s="w"
39 if [ -n "$p" ] 39 if [ -n "$p" ]
40 then 40 then
41 while read -r L 41 while read -r L
42 do 42 do
43 if [ "$s" = "w" ] 43 if [ "$s" = "w" ]
54 printf "%s\n" "${L%% 54 printf "%s\n" "${L%%
55 }" 55 }"
56 fi 56 fi
57 continue 57 continue
58 fi 58 fi
59 if [ "$s" = "b" ] 59 if [ "$s" = "h" ]
60 then 60 then
61 # HTTP header 61 # HTTP header
62 case "$L" in 62 case "$L" in
63 63
64 ) s="b" ; n=0 ; continue ;; 64 ) s="b" ; n=0 ; continue ;;
65 Content-Length:\ *) bl=${L##*: } 65 Content-Length:\ *) bl=${L##*: }
66 bl=${bl%%*([ 66 bl=${bl%%*([
67 [:space:]])} 67 [:space:]])}
68 ;; 68 ;;
69 esac 69 esac
70 if [ -n "$w" ] 70 if [ -n "$h" ]
71 then 71 then
72 printf "%s\n" "${L%% 72 printf "%s\n" "${L%%
73 }" 73 }"
74 fi 74 fi
75 continue 75 continue
83 break 83 break
84 fi 84 fi
85 fi 85 fi
86 done 86 done
87 else 87 else
88 cat 88 # No flags,the whole thing
89 fi # No flags,the whole thing 89 cat
90 fi
91 }