[execline] Conditional export

From: Petr Vaněk <arkamar_at_atlas.cz>
Date: Thu, 23 Mar 2023 13:44:36 +0100

Hi execline enthusiasts,

I am trying to write an execline script which conditionally exports
variable only if a given file exists. I am basically trying to mimic
this shell script:

```
#! /bin/sh

FILE="file"

if [ -f "${FILE}" ]; then
        EXISTS="${FILE}"
fi

export EXISTS

env
```

I have come up with following solution, which does what I want but I am
wondering if there is a better way of expressing this in execline?

```
#! /bin/execlineb -P

define FILE "file"

backtick EXPORTER {
        foreground {
                if { eltest -f "${FILE}" }
                echo export EXISTS "${FILE}"
        }
}

importas -us EXPORTER EXPORTER "${EXPORTER}"

env
```

Cheers,
Petr
Received on Thu Mar 23 2023 - 13:44:36 CET

This archive was generated by hypermail 2.4.0 : Thu Mar 23 2023 - 13:45:10 CET