summaryrefslogtreecommitdiff
path: root/postpost/adj_input_param_pipe
blob: 76d37bba921244f9a0a42a1d8c9bc4707c0c3d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# usage: cat fromfile | ./adj_input_param &key name value > tofile

neof=true
todo=0
while $neof
do
  read s || neof=false
  case $todo in
    0)
      [ "$s" == "$1" ] && todo=1
    ;;
    1)
      if [ $(echo "$s" | grep -c "^ *$2 ") -eq 1 ]
      then
        echo -ne "$s" | sed "s/=.*$//"
        echo -ne "= "
        echo -ne "$3"
        echo "$s" | sed "s/ *#.*$/\n&/" | tail -n1
        todo=2
        continue
      fi
      [ $(echo "$s" | grep -c "^&") -eq 1 ] && todo=2
    ;;
    2)
  esac
  echo "$s"
done