Re: bash < execline > bash

From: Colin Booth <cathexis_at_gmail.com>
Date: Sun, 1 May 2016 01:00:11 -0700

On Sat, Apr 30, 2016 at 10:45 PM, Eric Vidal <eric_at_obarun.org> wrote:
> It is possible to have a zsh/bash and execlineb syntax on the same file?
With some work yes. By default any execline script plays nice with
interstitial programs that only do chain loading. So programs like
nice, time, etc are all fine. It does not play nice with programs that
terminate, however it provides the foreground and background programs
to handle that.
>
> For example :
> #!/bin/execlineb -P
>
> if [ -d /run/example ]; then
> s6-mkdir -m 0755 /run/example
> fi
Not an execline script, this is pure shell with an alternate mkdir
implementation. Using the execline interpreter is wrong here.
>
> or
>
> #!/bin/execlineb -P
>
> if { s6-test -d /run/example }
> mkdir -m 0755 /run/example
This is fine. The execline if program chain loads into the next
program if its test passes, and while mkdir (and s6-mkdir) are not
chain loading programs, as long as it is the last program in the
script it doesn't matter. If you wanted to have the script do more
work after the mkdir, you would need to rewrite your script as
follows:
#!/bin/execlineb -P
if {s6-test -d /run/example }
foreground { mkdir -m 0755 /run/example }
rest_of_program

foreground is used to wrap a normal, terminating program with one that
understands how to exec and is commonly used when a discrete one-shot
program is needed within an execline program.

Cheers!
-Colin

-- 
"If the doors of perception were cleansed every thing would appear to
man as it is, infinite. For man has closed himself up, till he sees
all things thru' narrow chinks of his cavern."
  --  William Blake
Received on Sun May 01 2016 - 08:00:11 UTC

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