changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/bullshit

changeset 7243: 34f64dcbbc25
parent: 27bea812d835
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 rfork e
3 if(~ $#1 0)
4  file=/lib/bullshit
5 if not
6  file=$1
7 awk '
8 function min(a, b){
9  if(a > b)
10  return b
11  else
12  return a
13 }
14 function suffix(){
15  if(hassuffix = (rand() < 0.2))
16  return suffixes[int(rand() * nsuffix)]
17  return ""
18 }
19 $2 == "*" { protocol[nprotocol++] = $1; next }
20 $2 == "$" { end[nend++] = $1; next }
21 $2 == "%" { suffixes[nsuffix++] = $1; next }
22 $2 == "^" { start[nstart++] = $1; next }
23 $2 == "|" { noend[nword] = 1 }
24 { word[nword++] = $1; next }
25 END {
26  srand()
27  last = -1
28  out = 0
29  total = int(rand() * 7) + 3
30  n = int(rand() * min(total - out, 3))
31  for(i = 0; i < n; i++)
32  printf "%s ", start[int(rand() * nstart)]
33  out += n
34  hassuffix = 0
35  n = int(rand() * min(total - out, 3))
36  for(i = 0; i < n; i++)
37  printf "%s%s ", word[last = int(rand() * nword)], suffix()
38  out += n
39  if(rand() > 0.5){
40  n = int(rand() * 3)
41  for(i = 0; i < n; i++)
42  printf "%s %s", protocol[int(rand() * nprotocol)], (i != n-1) ? "over " : ""
43  out += n
44  last = -1
45  hassuffix = 0
46  }
47  n = int(rand() * min(total - out, 3))
48  if(out + n == 1 || last == -1)
49  n += 2
50  for(i = 0; i < n; i++)
51  printf "%s%s ", word[last = int(rand() * nword)], suffix()
52  if(rand() < 0.1 || (last >= 0 && noend[last]) || hassuffix)
53  printf "%s ", end[int(rand() * nend)]
54  print ""
55 }
56 ' $file