Re: execline "importas" documentation question

2018-09-16 Thread Colin Booth
On Sun, Sep 16, 2018 at 08:35:57PM -0500, Brett Neumeier wrote:
> On Sun, Sep 16, 2018 at 5:49 PM Colin Booth  wrote:
> 
> > 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.
> >
> 
> Ha, it was definitely a brain cloud, but it wasn't that. bash was, of
> course, replacing ${FOO} with an empty string before running the importas
> command.
> 
> The expected behavior does indeed show up if you single-quote that word so
> that bash leaves it alone:
> 
> $ importas FOO FOO echo 'prefix${FOO}postfix'
> 
> $
> 
Glad that worked for you. Generally speaking when I'm doing oneliner
execline testing I send the whole thing to execlineb -c in order to
guarantee that the shell isn't breaking anything. This matters even more
when you start using stuff that needs blocks.

-- 
Colin Booth


Re: execline "importas" documentation question

2018-09-16 Thread Brett Neumeier
On Sun, Sep 16, 2018 at 5:49 PM Colin Booth  wrote:

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

Ha, it was definitely a brain cloud, but it wasn't that. bash was, of
course, replacing ${FOO} with an empty string before running the importas
command.

The expected behavior does indeed show up if you single-quote that word so
that bash leaves it alone:

$ importas FOO FOO echo 'prefix${FOO}postfix'

$


-- 
Brett Neumeier (bneume...@gmail.com)


Re: execline "importas" documentation question

2018-09-16 Thread Colin Booth
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  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


execline "importas" documentation question

2018-09-16 Thread Brett Neumeier
Hi,

The documentation for importas says:

"When *envvar* is undefined, and the -D option is not given, any variable
substitution  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...)

-- 
Brett Neumeier (bneume...@gmail.com)