troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
633 stars 63 forks source link

trouble using redirects, pipes and parameter expansions in 'run' and 'task' #353

Closed cornerfix closed 1 year ago

cornerfix commented 1 year ago

In finit documentation it is stated that for commands after 'task [xxx]' and 'run [xxx]' finit launches shell, so using pipes, redirects, etc. is ok.

However, I have trouble doing:

task [06] kill -TERM $(pgrep sshd)

and even, trying to test what is happening: task [2345] date >> /runs.txt

both commands produce errors in dmesg and on linux console.

second one says, on console: sh: eval: line 0: syntax error: unexpected redirection

and in dmesg: finit[1]:service_start():date: failed wordexp(>>): 5

runs.txt remains empty - i.e. the command is not executed

sh -c "date >> /runs.txt" correctly yields a line in runs.txt

Is it possible that command parsing in finit somehow garbles symbols >, >> and $, possibly because of some issue with symbols escaping ?

I have 2 tesing VMs for finit - one with alpine linux 3.7 and other with artix linux (latest iso from 01.apr.2023). This happens in both VMs.

troglobit commented 1 year ago

The .conf files are not shell scripts, only basic variable expansion from environment files is allowed. To do what you want to do you have to use wrapper scripts, or simply package your task as a plain script.

troglobit commented 1 year ago

Closing due to lack of activity.