aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@localhost>2013-01-06 21:58:04 -0800
committerroot <root@localhost>2013-01-06 21:58:04 -0800
commit6fb48d0eea204b400f81a894dfd9880f69e639a6 (patch)
treeb75a3617a6d3b168de8d26884b373b6183f2bc74
parent3cddb977c4ac88e142488e350764ed23fa447b17 (diff)
downloadgit-remote-gcrypt-6fb48d0eea204b400f81a894dfd9880f69e639a6.zip
git-remote-gcrypt-6fb48d0eea204b400f81a894dfd9880f69e639a6.tar.gz
git-remote-gcrypt-6fb48d0eea204b400f81a894dfd9880f69e639a6.tar.bz2
Simplify line_count and pick_fields
-rwxr-xr-xgit-remote-gcrypt25
1 files changed, 10 insertions, 15 deletions
diff --git a/git-remote-gcrypt b/git-remote-gcrypt
index 81477e4..cb3dfea 100755
--- a/git-remote-gcrypt
+++ b/git-remote-gcrypt
@@ -85,16 +85,14 @@ append_to()
# $2 input value
pick_fields_1_2()
{
- local f_ret= f_line= f_var= f_oifs="$IFS" IFS=
- f_var=$1
- IFS=$Newline
- for f_line in $2
+ local f_ret= f_one= f_two=
+ while read f_one f_two _ # from << here-document
do
- IFS=$f_oifs
- set -- $f_line
- f_ret=$f_ret"${1:-} ${2:-}"$Newline
- done
- setvar "$f_var" "${f_ret#$Newline}"
+ f_ret="$f_ret$f_one $f_two$Newline"
+ done <<EOF
+$2
+EOF
+ setvar "$1" "${f_ret#$Newline}"
}
# Take all lines matching $2 (full line)
@@ -118,13 +116,10 @@ filter_to()
# Output the number of lines in $1
line_count()
{
- local f_x=0 IFS=
+ local IFS=
IFS=$Newline
- for f_line in $1
- do
- f_x=$(($f_x + 1))
- done
- xecho "$f_x"
+ set -- $1
+ xecho "$#"
}