Re: My script makes a defunct subshell and sticks on read

2018-01-30 Thread Øyvind Hvidsten

On 30/01/18 22:51, Chet Ramey wrote:

On 1/30/18 3:04 PM, Øyvind Hvidsten wrote:


Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
     Running the included script, which does nothing useful but is cut down
a lot to demonstrate the issue, my main computer (amd64 based) counts to
several million, then Bash stops responding, using 100% cpu and ends up
with a defunct subshell. On my Raspberry Pi, running Raspbian Stretch and
the same version of Bash (4.4.12), the same thing happens after only a few
thousand iterations.

Repeat-By:
     for ((i=0; ; i++)); do ((i%100)) || echo $i; exec {fd}<> >(:); read -t
0.001 -u $fd; exec {fd}>&-; done


In one sense, it's surprising that this works at all. You're opening a file
descriptor read-write (and trying to read from it) to a pipe that's opened
for writing only (the >(command) form is supposed to be used by processes
that write to the resulting file).

Yes. It's actually a rather neat hack if one wants to sleep without the 
"sleep" command or bash addons. I'm chasing a more complex issue though, 
and I'm wondering if whatever happens here could be happening with 
subshells in general.




Re: My script makes a defunct subshell and sticks on read

2018-01-30 Thread Chet Ramey
On 1/30/18 3:04 PM, Øyvind Hvidsten wrote:

> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
> 
> Description:
>     Running the included script, which does nothing useful but is cut down
> a lot to demonstrate the issue, my main computer (amd64 based) counts to
> several million, then Bash stops responding, using 100% cpu and ends up
> with a defunct subshell. On my Raspberry Pi, running Raspbian Stretch and
> the same version of Bash (4.4.12), the same thing happens after only a few
> thousand iterations.
> 
> Repeat-By:
>     for ((i=0; ; i++)); do ((i%100)) || echo $i; exec {fd}<> >(:); read -t
> 0.001 -u $fd; exec {fd}>&-; done

In one sense, it's surprising that this works at all. You're opening a file
descriptor read-write (and trying to read from it) to a pipe that's opened
for writing only (the >(command) form is supposed to be used by processes
that write to the resulting file).

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



My script makes a defunct subshell and sticks on read

2018-01-30 Thread Øyvind Hvidsten

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib 
-Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
-fdebug-prefix-map=/build/bash-7fckc0/bash-4.4=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie 
-Wno-parentheses -Wno-format-security
uname output: Linux vampiric 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 
(2017-09-28) x86_64 GNU/Linux

Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
Running the included script, which does nothing useful but is cut 
down a lot to demonstrate the issue, my main computer (amd64 based) 
counts to several million, then Bash stops responding, using 100% cpu 
and ends up with a defunct subshell. On my Raspberry Pi, running 
Raspbian Stretch and the same version of Bash (4.4.12), the same thing 
happens after only a few thousand iterations.


Repeat-By:
for ((i=0; ; i++)); do ((i%100)) || echo $i; exec {fd}<> >(:); read 
-t 0.001 -u $fd; exec {fd}>&-; done




Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Chet Ramey
On 1/30/18 2:07 PM, Larissa Braz wrote:

> I was running it using Ubuntu 14.04 LTS. I used the README instructions:
> "To compile Bash, type `./configure', then `make'. "
> 
> git clone http://git.savannah.gnu.org/git/bash
> 
> ./configure
> make
>  
> 
> There doesn't seem to be. Running these commands on an ubuntu 14.04 system
> with gcc-4.8 results in a working bash binary:
> 
> 
> git clone http://git.savannah.gnu.org/git/bash
> 
> cd bash
> bash ./configure -C
> make
> ./bash -c 'echo $BASH_VERSION'
> ./bash --version
> 
> The error disappears when I use "bash ./configure -C" instead of just
> "./configure". Is it ok to use it instead of the README instructions?

I think it's something specific to your system.

I ran `bash ./configure ; make' and got a working binary. I ran
`sh ./configure ; make' and `./configure ; make' (they're equivalent)
and got working binaries with both.

I guess you should do whatever your system needs to get a working binary.

Chet

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



Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Larissa Braz
Hi,

2018-01-30 12:01 GMT-03:00 Chet Ramey :

> On 1/30/18 8:51 AM, Chet Ramey wrote:
>
> > So if there's a problem with this kind of thing in gcc-4.8, I'd like to
> > get some more information about what it is.
>
>
I was running it using Ubuntu 14.04 LTS. I used the README instructions:
"To compile Bash, type `./configure', then `make'. "

git clone http://git.savannah.gnu.org/git/bash
./configure
make


> There doesn't seem to be. Running these commands on an ubuntu 14.04 system
> with gcc-4.8 results in a working bash binary:


> git clone http://git.savannah.gnu.org/git/bash
> cd bash
> bash ./configure -C
> make
> ./bash -c 'echo $BASH_VERSION'
> ./bash --version
>
The error disappears when I use "bash ./configure -C" instead of just
"./configure". Is it ok to use it instead of the README instructions?

Thanks,

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



-- 
Larissa Braz


Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Chet Ramey
On 1/30/18 8:51 AM, Chet Ramey wrote:

> So if there's a problem with this kind of thing in gcc-4.8, I'd like to
> get some more information about what it is.

There doesn't seem to be. Running these commands on an ubuntu 14.04 system
with gcc-4.8 results in a working bash binary:

git clone http://git.savannah.gnu.org/git/bash
cd bash
bash ./configure -C
make
./bash -c 'echo $BASH_VERSION'
./bash --version


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



Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Chet Ramey
On 1/30/18 8:44 AM, Chet Ramey wrote:

>> > I found the error bellow when I tried to compile the code.
>> >
>> > execute_cmd.c:4293:14: error: ‘eval_builtin’ undeclared (first use in 
>> this
>> > function)
>>
>> That's interesting, since none of the patches mention eval_builtin, and
>> there's no mention of eval_builtin on the source line in that message.
>>
>> Sorry, in the last commit the correct line is 4450 :) 
> 
> I still don't see it:
> 
> $ sed -n '4450{p;q;}' execute_cmd.c
>  flags that will exit the shell on an error if -e is set.  If the

And if you're wondering:

$ grep eval_builtin builtins/builtext.h
extern int eval_builtin __P((WORD_LIST *));
$ grep builtext.h execute_cmd.c
#include "builtins/builtext.h"  /* list of builtins */

So if there's a problem with this kind of thing in gcc-4.8, I'd like to
get some more information about what it is.

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



Re: anomalous behaviour of ls command

2018-01-30 Thread Ilkka Virta

On 30.1. 20:54, ken young wrote:

I have a directory with four files A Z a z only.
"ls [A-Z]" displays only 3 files A Z   z   ;a is missing
"ls [a-z]" displays only 3 files A   a z   ;Z is missing


Basically, your locale orders the letters as aAbBcC...yYzZ, so Z comes 
after z and [a-z] misses it. Similarly for a and [A-Z]. You can see the 
ordering if you do 'echo *' or such.


'shopt -s globasciiranges' should make [a-z] only match the 26 ASCII 
lowercase letters, and 'shopt -s nocaseglob' should make the globs match 
regardless of lettercase (it would also make a* match A).



--
Ilkka Virta / itvi...@iki.fi



Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Chet Ramey
On 1/30/18 8:39 AM, Larissa Braz wrote:
> 
> 2018-01-30 10:34 GMT-03:00 Chet Ramey  >:
> 
> On 1/30/18 8:10 AM, Larissa Braz wrote:
> > Bash version: last commit in repository (
> > http://git.savannah.gnu.org/cgit/bash.git
> )
> > GCC version: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
> >
> > Hi,
> > I found the error bellow when I tried to compile the code.
> >
> > execute_cmd.c:4293:14: error: ‘eval_builtin’ undeclared (first use in 
> this
> > function)
> 
> That's interesting, since none of the patches mention eval_builtin, and
> there's no mention of eval_builtin on the source line in that message.
> 
> Sorry, in the last commit the correct line is 4450 :) 

I still don't see it:

$ sed -n '4450{p;q;}' execute_cmd.c
 flags that will exit the shell on an error if -e is set.  If the



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



Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Larissa Braz
2018-01-30 10:34 GMT-03:00 Chet Ramey :

> On 1/30/18 8:10 AM, Larissa Braz wrote:
> > Bash version: last commit in repository (
> > http://git.savannah.gnu.org/cgit/bash.git)
> > GCC version: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
> >
> > Hi,
> > I found the error bellow when I tried to compile the code.
> >
> > execute_cmd.c:4293:14: error: ‘eval_builtin’ undeclared (first use in
> this
> > function)
>
> That's interesting, since none of the patches mention eval_builtin, and
> there's no mention of eval_builtin on the source line in that message.
>
Sorry, in the last commit the correct line is 4450 :)

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



-- 
Larissa Braz


Re: error: ‘eval_builtin’ undeclared

2018-01-30 Thread Chet Ramey
On 1/30/18 8:10 AM, Larissa Braz wrote:
> Bash version: last commit in repository (
> http://git.savannah.gnu.org/cgit/bash.git)
> GCC version: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
> 
> Hi,
> I found the error bellow when I tried to compile the code.
> 
> execute_cmd.c:4293:14: error: ‘eval_builtin’ undeclared (first use in this
> function)

That's interesting, since none of the patches mention eval_builtin, and
there's no mention of eval_builtin on the source line in that message.


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



Re: anomalous behaviour of ls command

2018-01-30 Thread Greg Wooledge
On Tue, Jan 30, 2018 at 01:54:36PM -0500, ken young wrote:
> uname output: Linux Microknoppix 4.12.7-64 #13 SMP PREEMPT Tue Aug 15 
> 04:56:38 CEST 2017 x86_64 GNU/Linux
> Machine Type: i686-pc-linux-gnu
> 
> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
> 
> I have a directory with four files A Z a z only.
> "ls [A-Z]" displays only 3 files A Z   z   ;a is missing
> "ls [a-z]" displays only 3 files A   a z   ;Z is missing

The behavior of range expressions in globs depends on your locale
setting.  The legacy range expressions [A-Z] and [a-z] only work
the way you expect when your locale is set to "C" or "POSIX".

If you want to match only uppercase letters (whatever those are in
your locale), you must use [[:upper:]] instead.  To match only
lowercase letters (whatever those are), use [[:lower:]] instead.

See  for more details.

wooledg:~$ mkdir /tmp/x && cd "$_"
wooledg:/tmp/x$ touch A Z a z
wooledg:/tmp/x$ ls [A-Z]
A  z  Z
wooledg:/tmp/x$ ls [[:upper:]]
A  Z
wooledg:/tmp/x$ ls [[:lower:]]
a  z
wooledg:/tmp/x$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=



anomalous behaviour of ls command

2018-01-30 Thread ken young
Please find enclosed bashbug file.

From: knoppi
To: bug-bash@gnu.org,b...@packages.debian.org
Subject: [behaviour of ls]


Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-w_CE2V/bash-4.4=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie 
-Wno-parentheses -Wno-format-security
uname output: Linux Microknoppix 4.12.7-64 #13 SMP PREEMPT Tue Aug 15 04:56:38 
CEST 2017 x86_64 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
[Detailed description of the problem, suggestion, or complaint.]
ls does not list the expected files

Repeat-By:
[Describe the sequence of events that causes the problem
to occur.]
I have a directory with four files A Z a z only.
"ls [A-Z]" displays only 3 files A Z   z   ;a is missing
"ls [a-z]" displays only 3 files A   a z   ;Z is missing

Fix:
[Description of how to fix the problem.  If you don't know a
fix for the problem, don't include this section.]


error: ‘eval_builtin’ undeclared

2018-01-30 Thread Larissa Braz
Bash version: last commit in repository (
http://git.savannah.gnu.org/cgit/bash.git)
GCC version: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

Hi,
I found the error bellow when I tried to compile the code.

execute_cmd.c:4293:14: error: ‘eval_builtin’ undeclared (first use in this
function)


Thank you,

-- 
Larissa Braz


Re: Bracketed paste mode breaks cooked mode's tab + backspace

2018-01-30 Thread Phi Debian
Hi Egmont

On Tue, Jan 30, 2018 at 9:47 AM, Egmont Koblinger  wrote:

> Not sure why you don't see this bug. (You have at least v4.4, and
> started a new shell after enabling bracketed paste, is that right?)
> One theoretical explanation could be that your kernel's tty driver is
> slightly different and expects the leading ESC byte to also move the
> cursor, resulting in 8 characters in total, making no difference in
> the modulo 8 computation for the tabs. (I don't think this is the
> explanation, though.)

I guess I got an std kernel driver :)
TC$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 16.04.3 LTS
Release:16.04
Codename:   xenial



>
> Even without bracketed paste mode, the issue should be reproducible
> with commands like:
> echo -ne '\e[1m'; cat
> Obviously it's not bash's fault and there's nothing bash could or
> should do with this one.

Partially reproduce,
   is ok, i.e jump fwd 8 and backward 8
XX  is ok got X jump fwd 7 X backward 7
Xwrong got X jump fwd 7 backward 4 (yet ok in the buffer)

>
> gnome-terminal doesn't use X resources either. gnome-terminal and
> terminator both use the same VTE widget for terminal emulation, and
> both have a setting under profile prefs -> compatibility to specify
> what Backspace and Delete do.

Gnome-terminal has its own backspace key mapping (so no xresource, yet
mapped ok), terminator unfortunatly don't have it :)

xterm use xresources, that what I use i.e

xmodmap backspace give 0x8
xresources VT100 Backsapce 0x08
stty erase ^H

With that I am almost an happy camper :)


Cheers,
Phi



Re: Bracketed paste mode breaks cooked mode's tab + backspace

2018-01-30 Thread Egmont Koblinger
Hi Chet,

> It seems like adding \r to the end of the sequence to turn off bracketed
> paste mode should do the trick.

Yup, I confirm that adding \r to BRACK_PASTE_FINI fixes the problem,
this looks the simplest approach.


cheers,
egmont



Re: Bracketed paste mode breaks cooked mode's tab + backspace

2018-01-30 Thread Egmont Koblinger
Hi Phi,

> This is not directly related to bash, it depend on the line discipline
> on the tty, I use  ^H as erase and got no problems with .

For me the same bug occurs after "stty erase ^H" and pressing ^H, too.
I would be really surprised if the kernel's logic on backspacing over
tabs (which is a purely output issue) depended on the choice of erase
character (which is an input issue).

Not sure why you don't see this bug. (You have at least v4.4, and
started a new shell after enabling bracketed paste, is that right?)
One theoretical explanation could be that your kernel's tty driver is
slightly different and expects the leading ESC byte to also move the
cursor, resulting in 8 characters in total, making no difference in
the modulo 8 computation for the tabs. (I don't think this is the
explanation, though.)

Even without bracketed paste mode, the issue should be reproducible
with commands like:
echo -ne '\e[1m'; cat
Obviously it's not bash's fault and there's nothing bash could or
should do with this one.

> gnome-term, xterm are ok with ,  generate 0x8, terminator
> is confused is it doesn't use X resouces and then can't map 0x8 on
> 

gnome-terminal doesn't use X resources either. gnome-terminal and
terminator both use the same VTE widget for terminal emulation, and
both have a setting under profile prefs -> compatibility to specify
what Backspace and Delete do.

> Using  generate  0x7f is a flaw since ages :)

Whether or not it is true (I'm not sure), it is irrelevant here :)


cheers,
egmont