Re: doesn't bash do variable subst. or quote removal on function statement

2016-01-12 Thread Linda Walsh



Chet Ramey wrote:

No.  The shell doesn't perform any word expansions on the `name' when
executing a function definition command.  Since the documentation doesn't
say it performs any expansions, why would you assume it does?
  

Because it does quote quote removal on other statements that _seem_ to be
of similar syntax.


I.e.:

declare  "ab=1"   "ab"=1   ab"=1"  a"b=1"  "a"b=1   a"b"=1   ab"=1"
 all appear to do quote removal, making them equivalent to
declare ab=1

vs. for function, where
one has:
 function a {(echo hi)}

then one might think, _at least_, that some similar syntax would
work like:

function "a" {(echo hi)}  function "a" "{(echo hi)}"

or even

declare -f a="{(echo hi)}"

_might_ work.

Also, from a documentation standpoint, not all behaviors are documented
in the manpage, like:

echo $[1+2]

as far as I can tell, isn't documented, yet not supporting
its behavior would break many older scripts











Re: doesn't bash do variable subst. or quote removal on function statement

2016-01-12 Thread Greg Wooledge
On Tue, Jan 12, 2016 at 11:52:47AM -0800, Linda Walsh wrote:
> Also, from a documentation standpoint, not all behaviors are documented
> in the manpage, like:
> 
> echo $[1+2]
> 
> as far as I can tell, isn't documented, yet not supporting
> its behavior would break many older scripts

That syntax has been deprecated for at least 15 years.  Nobody is
supposed to be using it.  It's undocumented ON PURPOSE, to try to make
people stop doing it.

If you have older scripts that use it, fix them now.



Re: implicit redirection of background within pipeline

2016-01-12 Thread Chet Ramey
On 1/10/16 2:23 AM, Martin D Kealey wrote:

> Bash Version: 4.3
> Patch Level: 11
> Release Status: release
> 
> Description:
>   The first backgrounded element within a pipeline component has its
>   stdin redirected to /dev/null; this does not apply to the second and
>   subsequent background elements.
> 
>   On a Linux system this can be observed with:
>   echo x | ( ls -ld /proc/self/fd/0 &
>  ls -ld /proc/self/fd/0 &
>  wait )
> 
>   On other systems it is apparent simply with:
>   echo x | ( cat & wait )

Thanks for the report.  I fixed this family of problems and the fix will
be in the next bash release, as well as the next devel snapshot.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: doesn't bash do variable subst. or quote removal on function statement

2016-01-12 Thread Linda Walsh



Greg Wooledge wrote:

On Tue, Jan 12, 2016 at 11:52:47AM -0800, Linda Walsh wrote:
  

Also, from a documentation standpoint, not all behaviors are documented
in the manpage, like:

echo $[1+2]

as far as I can tell, isn't documented, yet not supporting
its behavior would break many older scripts



That syntax has been deprecated for at least 15 years.

---
   But why?  It's less noisy than any alternative.
It's not as if I can type echo $(1+2) and expect it to work.



  Nobody is
supposed to be using it.  It's undocumented ON PURPOSE, to try to make
people stop doing it.

If you have older scripts that use it, fix them now.
  

---
   Only in 3rd party scripts where scripts come with some product to be 
used
on *nix, which is why I worry about it.  I wouldn't want those scripts 
to become

my responsibility to "fix".

   Though, at one point, I seem to remember some wondering when systemd 
might

integrate a shell-service as it has many other *nix utils (somewhere around
the time it was integrating code to replace 'su' or 'sudo', I think).  
If that

happens, then it's clear where compatibility will go.





Re: implicit redirection of background within pipeline

2016-01-12 Thread Martin Kealey


On Mon, 11 Jan 2016, Chet Ramey wrote:
> "The standard input for an asynchronous list, before any explicit
> redirections are performed, shall be considered to be assigned to a file
> that has the same properties as /dev/null."

I thought the (only) point of that to avoid a background job reading the tty
in an environment that lacked job control.

The standard is actually a bit vague; under "Compound Commands" it mentions
that "Each redirection will apply to all the commands within the compound
command that do not explicitly override that redirection" but it fails to
mention that this applies to pipes as well; so I submit that it is a
reasonable interpretation that a pipe on an outer block counts as an
(explicit) redirection for the purpose of reading the "Asynchronous Lists"
sub section.

What do other shells do? Ksh? Dash? Zsh?

-Martin