summaryrefslogtreecommitdiff
path: root/scripts/value_fix.sh
blob: 38584019b0a10163c7ec11df21466d3686bedd20 (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
#!/bin/sh
# FILE: "/home/evmik/eagle/scripts/value_fix.sh"
# LAST MODIFICATION: "Fri, 18 Jul 2014 16:54:10 -0400 (evmik)"
# (C) 2014 by Eugeniy Mikhailov, <evgmik@gmail.com>
# $Id:$


# Tries to fix eagle schematic to board discrepancy if some one ascendantly changes values in schematic while
# the board file was not connected

# To avoid gotchas copy the board file into t.brd, it will be edited in place.
# Once you happy with fixes overwrite the original eagle board file with t.brd

# Look thought the diff and file list of parts with updated values
git diff | grep '+<part name="' |sed s/'+<part name="\([^"]*\)".*value="\([^"]*\).*'/'\1 \2'/ >part.list

# Now update components values in the board file.
# Assumes that board file is copied into t.brd file
cat part.list | \
while read part v
do
	echo zzz $part zzz $v
	sed -i s\z'\(<element name="\)'"$part"'\(".*value="\)[^"]*\(".*\)$'\z'\1'"$part"'\2'"$v"'\3'\z t.brd
done