Re: execline and $0-based stuff

2017-02-22 Thread Guillaume Perréal
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' '.*/getty-\([^/]*\)/run'

I have two other questions but I'll start proper mail threads.

--

Guillaume.


Le 22/02/2017 à 03:03, Casper Ti. Vector a écrit :

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
#!/bin/rc
fn car { echo $1 | sed 's/^.*\.//' }
fn cdr { echo $1 | sed 's/\.[^.]*$//' }
# ... [code used in other templates] ...
self=`{basename `{pwd}}
if (~ $self *.log) {
 logd=/var/log/`{cdr $self}
} else name=`{car $self}
# ... [code used in other templates] ...

On Sat, Feb 18, 2017 at 01:46:20PM +0100, gperr...@free.fr wrote:

extract a part of the path of the executed script ($0) in a variable




Re: execline and $0-based stuff

2017-02-21 Thread Casper Ti. Vector
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
> #!/bin/rc
> fn car { echo $1 | sed 's/^.*\.//' }
> fn cdr { echo $1 | sed 's/\.[^.]*$//' }
> # ... [code used in other templates] ...
> self=`{basename `{pwd}}
> if (~ $self *.log) {
> logd=/var/log/`{cdr $self}
> } else name=`{car $self}
> # ... [code used in other templates] ...

On Sat, Feb 18, 2017 at 01:46:20PM +0100, gperr...@free.fr wrote:
> extract a part of the path of the executed script ($0) in a variable

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C