xref: /freebsd/tests/sys/cddl/zfs/include/translatecommands.awk (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
1#! /usr/bin/awk -f
2# $FreeBSD$
3
4BEGIN {
5	print "# This file is autogenerated from commands.txt. Do not edit"
6	cmdstring = "export CMDS=\""
7	cmdch = 1
8	cmd_idx=0
9}
10
11# Strip comments
12{
13	gsub(/#.*/, "", $0)
14}
15
16# Strip blank lines
17/^[ ]*$/ {
18	next
19}
20
21# Process remaining lines
22{
23	gsub(/%%STFSUITEDIR%%/, stfsuitedir, $1)
24	fullcmd = $1
25	cmdname = $1
26	gsub(/.*\//, "", cmdname)
27	CMDNAME = toupper(cmdname)
28	allcmds[cmd_idx] = CMDNAME
29	cmd_idx += 1
30	printf "export %s=\"%s\"\n", CMDNAME, fullcmd
31}
32
33# Print CMDS
34END {
35	print ""
36	printf "export CMDS=\""
37	for (idx in allcmds)
38		printf "$%s ", allcmds[idx]
39	print "\""
40}
41