elglob -0 fs somedir/*
if { test -n $fs }
ln -t otherdir $fs

the test will fail if there’s more than one file in `somedir`.
Is there a way to put a split variable into one variable again?

 Your next door "echo" command will do just that (or s6-echo
if you risk having dashes and want reliable behaviour in all cases).

elglob -0 splitfs somedir/*
backtick -n fs { echo $splitfs }
importas -u fs fs
if { test -n $fs } ...


It feels kind of clumsy to use elglob, especially because of
the default verbatim input of the pattern if no expansion is
found. I can’t imagine any use case where I’d want that,
especially not as default behaviour.

 The shell has the exact same default behaviour. I didn't want to
gratuitously diverge from the shell. But I agree "elglob -0" is the
behaviour you want most of the time.


Another fun effect:

execlineb -c 'elglob -0 f doesnotexist/* if { test -z "${f}" } echo foo'
foo
execlineb -c 'elglob -0 f doesnotexist/* if { test -n "${f}" } echo foo'
foo

So for `test`, the ominous “zero string” of execline is both
empty and non-empty!
Is there some elaboration somewhere what this zero string is?
And how do work with it?

 It's not a "zero string". It's zero word. Which means the "${f}"
argument is replaced with nothing at all, not even an empty string.
So the tests resolve to:
test -z
and
test -n
which both return true.

--
 Laurent

Reply via email to