Re: execline globbing

2018-07-24 Thread Laurent Bercot

That brings me to another question: is there a collection of
more execline utilities somewhere? I suspect the standard
GNU coreutils are not quite to your liking in a lot of cases.


 The execline package has all the execline-specific utilities you
need to perform execline scripting (although if you have a bright
idea about something that's obviously missing, please share it).
GNU coreutils provide a completely different functionality, i.e.
basic Unix utilities - and if you don't like them, there are a ton
of other implementations of the same utilities: busybox, toybox,
sbase+ubase, etc.



Would you be open to switch the default behavior?
Maybe with a warning message on `-0` that it is the default
and will be removed after a few releases.
I suggest something like `-k` for “keep”.


 I don't think the benefits of changing the default are worth the
drawbacks and the effort. Again, the current default is how shell
globbing works, and I think there's value in aligning with that
behaviour. As long as the user has control, there's not much
incentive to change.

--
 Laurent



Re: execline globbing

2018-07-24 Thread Profpatsch


Laurent Bercot  writes:

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

That brings me to another question: is there a collection of
more execline utilities somewhere? I suspect the standard
GNU coreutils are not quite to your liking in a lot of cases.

>  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.

Would you be open to switch the default behavior?
Maybe with a warning message on `-0` that it is the default
and will be removed after a few releases.
I suggest something like `-k` for “keep”.


>  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.

Aha!

-- 
Written with Emacs (mu4e) on NixOS.
Q: Why is this email five sentences or less?
A: http://five.sentenc.es/
May take up to five days to read your message. If it’s urgent, call me.


Re: execline globbing

2018-07-24 Thread Laurent Bercot

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



execline globbing

2018-07-24 Thread Profpatsch
When I have a glob like:

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?

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.

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?

--
Written with Emacs (mu4e) on NixOS.
Q: Why is this email five sentences or less?
A: http://five.sentenc.es/
May take up to five days to read your message. If it=E2=80=99s urgent, call me.