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

Reply via email to