Re: execline "importas" documentation question

From: Colin Booth <colin_at_heliocat.net>
Date: Sun, 16 Sep 2018 22:49:46 +0000

On Sun, Sep 16, 2018 at 04:42:10PM -0500, Brett Neumeier wrote:
> Hi,
>
> The documentation for importas says:
>
> "When *envvar* is undefined, and the -D option is not given, any variable
> substitution <http://skarnet.org/software/execline/el_substitute.html> with
> *variable* as the key will return no word; that is true even when the ${
> *variable*} form to be substituted happens in the middle of a word (with a
> prefix and/or a postfix), which means the whole world will be deleted. If
> this is not the behaviour you want, use the -D option."
>
> I'm trying to figure out what that means. When I ensure that FOO is not set
> and run:
>
> importas FOO FOO echo prefix${FOO}postfix
>
> I get the output "prefixpostfix", which is identical to what I get if I add
> a -D option with an empty word. If the whole word were deleted, I'd expect
> to get empty output. (If the whole *world* were deleted, I'd expect to be
> floating in space...)
>
I think I know what is going on. I assume you're running this on the
commandline? If so, the shell is splitting prefix${FOO}postfix into
three words ("prefix", "$FOO", "postfix"), then importas is deleting the
middle one. If you write this as a full execline script like so:
$ execlineb -c 'importas FOO FOO echo prefix${FOO}postfix'
you'll see the full word deletion in action.

Cheers!
-- 
Interesting. I get the expected behavior. 
Colin Booth
Received on Sun Sep 16 2018 - 22:49:46 UTC

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