I also discovered that the "expr" command from busybox have some regexp
support, e.g :
expr 'match' '/some/path/getty-tty1/run' '.*/getty-\([^/]*\)/run'
Exits with 0 and prints "tty1".
While this doesn't print anything and exits with 1 :
expr 'match' '/some/path/not-a-tty/run' '.*/get
An example of my attempt, already working on at least 2 Alpine machines:
> $ ls -d /etc/s6-rc/main/*getty*
> /etc/s6-rc/main/getty.tty1
> $ cat /etc/s6-rc/base/getty/run
> #!/bin/rc -e
> exec >[2=1]
> . /etc/s6-rc/bin/fn.rc
> exec `{cdr $self} 38400 $name linux
> $ cat /etc/s6-rc/bin/fn.rc
> #!
Hello there,
I would like to extract a part of the path of the executed script ($0)
in a variable, e.g. if the script was run as /some/path/getty-tty1/run,
I would like to extract "tty1" from the path, or similary, extract
"dropbear" from /some/path/dropbear-log/run. This would allow to write