feat: add nuke-state

...duh
This commit is contained in:
ptrcnull 2022-08-05 22:36:46 +02:00
parent 02ec07cef2
commit b9b3f93f51
2 changed files with 26 additions and 10 deletions

View file

@ -10,6 +10,7 @@ a simple shift register built on piperw(1)
init-state <name>
load-state <name> <target>
save-state <name> <value>
nuke-state <name>
```
```sh
@ -17,15 +18,18 @@ save-state <name> <value>
init-state flip
save-state flip "up"
forstdin -E line
load-state flip current
println "! state: $current"
ifelse { s6-test "$line" = "flip" } {
println "! flipping state"
ifelse { s6-test "$current" = "up" } {
save-state flip "down"
foreground {
forstdin -E line
load-state flip current
println "! state: $current"
ifelse { s6-test "$line" = "flip" } {
println "! flipping state"
ifelse { s6-test "$current" = "up" } {
save-state flip "down"
}
save-state flip "up"
}
save-state flip "up"
}
save-state flip "$current"
save-state flip "$current"
}
nuke-state flip
```

12
nuke-state Executable file
View file

@ -0,0 +1,12 @@
#!/bin/execlineb
importas -ui name 1
importas -ui rdfd ELSTATE_${name}
backtick -E wrfd { s6-expr "$rdfd" + 1 }
fdclose ${rdfd}
fdclose ${wrfd}
shift
elgetpositionals
$@