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> init-state <name>
load-state <name> <target> load-state <name> <target>
save-state <name> <value> save-state <name> <value>
nuke-state <name>
``` ```
```sh ```sh
@ -17,7 +18,8 @@ save-state <name> <value>
init-state flip init-state flip
save-state flip "up" save-state flip "up"
forstdin -E line foreground {
forstdin -E line
load-state flip current load-state flip current
println "! state: $current" println "! state: $current"
ifelse { s6-test "$line" = "flip" } { ifelse { s6-test "$line" = "flip" } {
@ -28,4 +30,6 @@ forstdin -E line
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
$@