Re: execline and $0-based stuff

From: Laurent Bercot <>
Date: Sat, 18 Feb 2017 14:12:50 +0000

>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
>templated services quite easily using symlinks. However, I noticed
>there is no substitution nor sed equivalent in the execline/s6 tool
>suite ; even a grep-like tool that output capturing groups would do the
>trick. I think it would be doable with the existing set of tools but
>would be quite heavy.

  Indeed. execline is meant to be the glue between programs, not a
programming language, so string operations are not part of it. If you
write a shell program using sed, grep and similar utilities, you can
translate it verbatim to execline and it will work in the exact same way
(it will probably be more verbose because you'd have to invoke commands
such as backtick and pipeline, to translate ` and | from the shell).
But if you write a shell program using specific shell constructs such as
${foo##bar}, then you're using the shell as a programming language, and
there is no equivalent in execline.

  My advice is simply to write your run scripts in shell as soon as the
complexity justifies it.

Received on Sat Feb 18 2017 - 14:12:50 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC