Description
Given a dependency file where each line describes module(s) on which a give one
depends.
For example, in the following datafile,
- D:A,F,C means module `D' depends on `A', `F' and `C'.
Therefore, modules `A', `F' and `C' must be installed before `D'.
- B: means module `B' does not depend on any other.
We divide the job into two stages:
- Figure out what modules do not depend on others.
They are `B' and `H' in this case.
The first script will generate
B|H,
which will be used as an ERE in the second stage .
- Remove those modules from the dependency lists.
For example, transform F:B,E to
F:E
|
| Raw Input
|
| Desired Output
| D:A,F,C
C:H
F:B,E,H
B:
E:H
H:
A:G
G:B
|
| B|H
|
|
Script and Comments
Script1 [ 1] /^[^:]+:$/H
[ 2] $!d
[ 3] g
[ 4] s/(^\n|:$)//g
[ 5] s/:\n/|/g
| |
| Raw Input
|
| Desired Output
| D:A,F,C
C:H
F:B,E,H
B:
E:H
H:
A:G
G:B
|
| D:A,F,C
C:
F:E
E:
A:G
G:
|
|
Script and Comments
Script1 [ 1] /^($MOD):$/d
[ 2] :loop
[ 3] s/(:|,)($MOD)(,|$)/\1/
[ 4] t loop
[ 5] s/,$//
| |
|