Using Clang's static analyzer on bash

2017-04-23 Thread Eduardo Bustamante
I built bash using scan-build (https://clang-analyzer.llvm.org/scan-build.html) and I noticed that it was able to detect the null pointer dereference reported earlier by Jaren (https://lists.gnu.org/archive/html/bug-bash/2017-04/msg00100.html). dualbus@debian:~/src/gnu/bash$ scan-build-3.9 make sc

Re: Curious case of arithmetic expansion

2017-04-23 Thread Chet Ramey
On 4/23/17 4:25 PM, Florian Mayer wrote: >> That's not a reasonable expectation. > Why not? Why is it not reasonable to expect an intuitive > result from (())? The most intuitive thing, in my opinion, > would be to use nameref for side effects by default, because in order > to get a value from an i

Re: I Don't think it; 's a Bash bug in the classical sense but it is still very important for me to share with you

2017-04-23 Thread Chet Ramey
On 4/23/17 2:52 AM, Noneofthebusiness Ofsomehere wrote: > There is an annoying problem I struggle with that might be associated with > tab completion. I would like to share it with you. It might be a bug. I > really don't know and I'm new to Linux and programming, hence I am being > extra careful i

Re: Curious case of arithmetic expansion

2017-04-23 Thread Eduardo Bustamante
On Sun, Apr 23, 2017 at 3:25 PM, Florian Mayer wrote: [...] > Why not? Why is it not reasonable to expect an intuitive > result from (())? The most intuitive thing, in my opinion, > would be to use nameref for side effects by default, because in order > to get a value from an id, (()) already foll

I Don't think it; 's a Bash bug in the classical sense but it is still very important for me to share with you

2017-04-23 Thread Noneofthebusiness Ofsomehere
There is an annoying problem I struggle with that might be associated with tab completion. I would like to share it with you. It might be a bug. I really don't know and I'm new to Linux and programming, hence I am being extra careful in naming this a bug: https://unix.stackexchange.com/questio

Re: Curious case of arithmetic expansion

2017-04-23 Thread Florian Mayer
> That's not a reasonable expectation. Why not? Why is it not reasonable to expect an intuitive result from (())? The most intuitive thing, in my opinion, would be to use nameref for side effects by default, because in order to get a value from an id, (()) already follows namerefs. So if you have

Re: Curious case of arithmetic expansion

2017-04-23 Thread Chet Ramey
On 4/23/17 8:28 AM, Florian Mayer wrote: > What I’m saying is, that if bash does recursively apply expansion > mechanisms on the identifiers until it can retrieve a number, > it should do it symmetrically. That's not a reasonable expectation. Here's how it works. When bash reads a token, such a

Re: Segfault when unsetting READLINE_LINE inside 'bind -x'

2017-04-23 Thread Chet Ramey
On 4/23/17 12:14 PM, Eduardo Bustamante wrote: > I tried the following patch: > > dualbus@debian:~/src/gnu/bash$ git diff -- bashline.c > diff --git a/bashline.c b/bashline.c > index 129714aa..7884416a 100644 > --- a/bashline.c > +++ b/bashline.c > @@ -2545,7 +2545,7 @@ static void > maybe_make_

Re: Segfault when unsetting READLINE_LINE inside 'bind -x'

2017-04-23 Thread Eduardo Bustamante
On Sun, Apr 23, 2017 at 12:56 AM, Jaren Stangret wrote: > Hello, > > Instead of segfaulting, BASH should ensure READELINE_LINE is unset or set > and empty. I am able to reproduce this with the latest devel branch. Here's the stack trace: Program received signal SIGSEGV, Segmentation fault. 0x000

Re: Curious case of arithmetic expansion

2017-04-23 Thread Florian Mayer
> what shoud echo $((foo++)) do? Give out an error message hopefully (and it does), because the expression (bar+14+moo*2)++ makes no semantical sense in terms of arithmetic expressions the bash uses, because ++ only can apply to locations and (bar+14+moo*2) evaluates to a number no matter the con

Segfault when unsetting READLINE_LINE inside 'bind -x'

2017-04-23 Thread Jaren Stangret
Hello, Instead of segfaulting, BASH should ensure READELINE_LINE is unset or set and empty. *Configuration Information:* Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64

Re: Curious case of arithmetic expansion

2017-04-23 Thread Pierre Gaston
On Sun, Apr 23, 2017 at 4:07 PM, Florian Mayer wrote: > It does not matter, how this construct in this particular context is > called. > The difference between $(()) and (()) is that $(()) actually expands to > something > whereas (()) just executes a C-like expression. In (()) > can also > incl

Re: Curious case of arithmetic expansion

2017-04-23 Thread Florian Mayer
> And in my opinion those are not correct... So in a scenario like the mentioned $ foo=bar; bar=moo; moo=123 the line $ ((foo++)); echo $foo $bar $moo should actually evaluate to „bar moo 124“ or at least say something like „error, can not execute side effects, because I can’t keep track of wha

Re: Curious case of arithmetic expansion

2017-04-23 Thread Florian Mayer
It does not matter, how this construct in this particular context is called. The difference between $(()) and (()) is that $(()) actually expands to something whereas (()) just executes a C-like expression. In (()) can also include assignments, as the bash manual that you properly cited, also e

Re: Curious case of arithmetic expansion

2017-04-23 Thread Pierre Gaston
On Sun, Apr 23, 2017 at 3:28 PM, Florian Mayer wrote: > What I’m saying is, that if bash does recursively apply expansion > mechanisms on the identifiers until it can retrieve a number, > it should do it symmetrically. That is, > it should remember what chain of expansion had been necessary for >

Re: Curious case of arithmetic expansion

2017-04-23 Thread Florian Mayer
What I’m saying is, that if bash does recursively apply expansion mechanisms on the identifiers until it can retrieve a number, it should do it symmetrically. That is, it should remember what chain of expansion had been necessary for a particular number to appear at the end of the expansion. So i

Re: Curious case of arithmetic expansion

2017-04-23 Thread Pierre Gaston
On Sun, Apr 23, 2017 at 1:12 PM, Florian Mayer wrote: > Consider > > $ foo=bar; bar=moo; moo=123 > $ echo $foo $bar $moo > => bar moo 123 > $ echo $((foo)) > => 123 > $ echo $foo $bar $moo > => bar moo 123 > $ # so far so good but > $ ((foo++)) > $ echo $foo $bar $moo > => 123 moo 123 > > Now my

Curious case of arithmetic expansion

2017-04-23 Thread Florian Mayer
Consider $ foo=bar; bar=moo; moo=123 $ echo $foo $bar $moo => bar moo 123 $ echo $((foo)) => 123 $ echo $foo $bar $moo => bar moo 123 $ # so far so good but $ ((foo++)) $ echo $foo $bar $moo => 123 moo 123 Now my chain of indirections is broken…