aboutsummaryrefslogtreecommitdiff
path: root/drivers/md/unroll.awk
blob: c6aa03631df86d7837ea56d28d6059799803ef5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This filter requires one command line option of form -vN=n
# where n must be a decimal number.
#
# Repeat each input line containing $$ n times, replacing $$ with 0...n-1.
# Replace each $# with n, and each $* with a single $.

BEGIN {
	n = N + 0
}
{
	if (/\$\$/) { rep = n } else { rep = 1 }
	for (i = 0; i < rep; ++i) {
		tmp = $0
		gsub(/\$\$/, i, tmp)
		gsub(/\$\#/, n, tmp)
		gsub(/\$\*/, "$", tmp)
		print tmp
	}
}