sed: Print bash environment
1
1 7.5 Print 'bash' Environment
1 ============================
1
1 This script strips the definition of the shell functions from the output
1 of the 'set' Bourne-shell command.
1
1 #!/bin/sh
1
1 set | sed -n '
1 :x
1
1 # if no occurrence of "=()" print and load next line
1 /=()/! { p; b; }
1 / () $/! { p; b; }
1
1 # possible start of functions section
1 # save the line in case this is a var like FOO="() "
1 h
1
1 # if the next line has a brace, we quit because
1 # nothing comes after functions
1 n
1 /^{/ q
1
1 # print the old line
1 x; p
1
1 # work on the new line now
1 x; bx
1 '
1