summaryrefslogtreecommitdiff
path: root/merge-kernel-configs
blob: d8d86e376dc81490fc063e0e89f30ed22416a4cf (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
#!/bin/bash

# merge-kernel-configs $out
# (reads from stdin)

rm -f "$1"
touch "$1"

while read -r line; do
  variable=$(
    printf '%s\n' "${line}" | \
      sed '
        s/^# \(\S\+\) is not set$/\1/
        t
        s/=.*$//
        t
        d
      '
  )
  if [ -z "${variable}" ] || \
    grep -q '^\(# \)\?'"${variable}"'[= ]' "$1"; then
    continue
  fi
  printf '%s\n' "${line}" >> \
    "$1"
done