Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Andreas Schwab
Dennis Williamson writes: > On Tue, Sep 1, 2015 at 4:24 PM, Andreas Schwab > wrote: > >> Dennis Williamson writes: >> >> > $ echo $((foo)) # expansion succeeds, indirection fails >> > dash: 4: Illegal number: bar >> >> The indirection didn't fail, it just didn't produce a number, so the >> exp

Re: \c-handling in $'-strings

2015-09-02 Thread Chet Ramey
On 9/1/15 6:46 PM, Helmut Karlowski wrote: > Do you refer to the table titled "Circumflex Control Characters in stty"? > > It states for example: > > ? Yeah, that's a problem. I've fixed that. > > Running: > > echo $'\c?' |od -a > echo $'\c[\c\\c]\c^\c_\c?' |od -a > > bash prints: > >

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Chet Ramey
On 9/1/15 4:13 PM, Dennis Williamson wrote: > The version of dash I have handy (0.5.7) has math support which IMHO is > broken: > > $ foo=bar > $ bar=5 > $ echo $foo > bar > $ echo $((foo)) > dash: 4: Illegal number: bar > $ echo $(($foo)) > 5 > $ echo $((bar)) > 5 > $ echo $(($bar)) > 5 Dash

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Chet Ramey
On 9/1/15 12:50 AM, Clint Hepner wrote: > Bash Version: 4.3 > Patch Level: 42 > Release Status: release > > Description: > > Parameter names are recursively evaluated in an arithmetic expression, but > this > is not done consistently. Parameter names are expanded and treated as expressions whe

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Chet Ramey
On 9/1/15 5:05 PM, Dennis Williamson wrote: > It's the line above those two where I demonstrate the failure in the > indirection and equivalency. > > $ echo $((foo)) # expansion succeeds, indirection fails > dash: 4: Illegal number: bar Because `foo' is expanded, but the value is not treated as

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Dennis Williamson
On Wed, Sep 2, 2015 at 2:16 AM, Andreas Schwab wrote: > Dennis Williamson writes: > > > I disagree. The _expansion_ produced "bar" > > That's not an expansion. Only $ introduces an expansion. > > Andreas. > > The $ is implied. -- Visit serverfault.com to get your system administration questio

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Greg Wooledge
On Wed, Sep 02, 2015 at 10:16:14AM -0500, Dennis Williamson wrote: > The $ is implied. That is completely absurd. (And wrong.)

\? is missing in "3.1.2.4 ANSI-C Quoting" in Bash Reference Manual

2015-09-02 Thread ziyunfei
bash-4.3$ echo $'\?' ? \? should be added there.

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Chet Ramey
On 9/2/15 11:19 AM, Greg Wooledge wrote: > On Wed, Sep 02, 2015 at 10:16:14AM -0500, Dennis Williamson wrote: >> The $ is implied. > > That is completely absurd. (And wrong.) Not exactly. When the arithmetic evaluator encounters a token that is of the form of a shell identifier (`bar'), in a co

Re: \? is missing in "3.1.2.4 ANSI-C Quoting" in Bash Reference Manual

2015-09-02 Thread Chet Ramey
On 9/2/15 10:00 AM, ziyunfei wrote: > bash-4.3$ echo $'\?' > ? > > \? should be added there. Backslash-escape sequences that are not present in the documentation are left unchanged. Posix leaves these up to the implementation. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Greg Wooledge
On Wed, Sep 02, 2015 at 11:24:42AM -0400, Chet Ramey wrote: > On 9/2/15 11:19 AM, Greg Wooledge wrote: > > On Wed, Sep 02, 2015 at 10:16:14AM -0500, Dennis Williamson wrote: > >> The $ is implied. > > > > That is completely absurd. (And wrong.) > > Not exactly. When the arithmetic evaluator enc

Word-splitting with here document?

2015-09-02 Thread Clint Hepner
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: darwin13.4.0 Compiler: clang Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='darwin13.4.0' -DCONF_MACHTYPE='x86_64-apple-darwin13.4.0' -DCONF_VENDOR='apple' -DLOCALEDIR='/usr/local/

Re: Why does a Bash shell script write prompts followed by reads and do it right?

2015-09-02 Thread Ángel González
Robert Parker wrote: > Yet when I attempt the same in a C program, the system always writes > 2 prompts, then waits for a read. > Does not matter if I write(1, "..."); read(0, number, buffer); or use > fputs("...", stdout); fgets(. > The result is the same. > And I have tried using readline wit

Re: Why does a Bash shell script write prompts followed by reads and do it right?

2015-09-02 Thread Robert Parker
Thanks guys. Code supplied: static void getuserinput(char *prompt, char *reply); static int getans(char *prompt, char *choices); int main(int argc, char **argv) { char namebuf[NAME_MAX]; char typebuf[NAME_MAX]; char defltbuf[NAME_MAX]; char codebuf[NAME_MAX]; char *eols = "\

Re: Why does a Bash shell script write prompts followed by reads and do it right?

2015-09-02 Thread Bob Proulx
Robert Parker wrote: > fputs(shortprompt, stdout); > fflush(stdin); Uhm... fflush'ing stdin? That doesn't make sense. Obviously you meant to flush stdout. fputs(shortprompt, stdout); fflush(stdout); That is likely the specific problem. Unfortunately I have no

Re: Word-splitting with here document?

2015-09-02 Thread Chet Ramey
On 9/2/15 2:14 PM, Clint Hepner wrote: > Bash Version: 4.3 > Patch Level: 30 > Release Status: release > > Description: >Unexpected word splitting in here string. According to the man page, > "Pathname expansion and word splitting are not performed." This is > essentially the same wordin

Re: Why does a Bash shell script write prompts followed by reads and do it right?

2015-09-02 Thread Eric Blake
On 09/02/2015 02:22 PM, Bob Proulx wrote: > Robert Parker wrote: >> fputs(shortprompt, stdout); >> fflush(stdin); > > Uhm... fflush'ing stdin? That doesn't make sense. There is one case where fflush(stdin) is useful on a terminal: it lets you discard any pending input. For exam

Re: \c-handling in $'-strings

2015-09-02 Thread Helmut Karlowski
Am 02.09.2015, 14:19 Uhr,SCHRIEB Chet Ramey : echo $'\c?' |od -a echo $'\c[\c\\c]\c^\c_\c?' |od -a bash prints: 000 us nl 002 000 esc fs c ] rs us us nl I'd expect: 000 del nl 002 000 esc fs gs rs us del nl Also the ] in the output seems wrong, looks

Re: \c-handling in $'-strings

2015-09-02 Thread Eric Blake
On 09/02/2015 03:10 PM, Helmut Karlowski wrote: >> >> The Posix standardization of $'...' requires that the character after the > > Where is that described? I could not find anything about $'...' in the > posix-docs. http://austingroupbugs.net/view.php?id=249 It's not part of POSIX yet; but the

Re: \? is missing in "3.1.2.4 ANSI-C Quoting" in Bash Reference Manual

2015-09-02 Thread ziyunfei
Sorry, I didn't understand your reply. What I'm saying is this: \? is shown in printf section: "Causes printf to expand backslash escape sequences in the corresponding argument, except that ‘\c’ terminates output, backslashes in ‘\'’, ‘\"’, and ‘\?’ are not removed, and octal escapes beginning

Re: Feature Request re: syslog and bashhist

2015-09-02 Thread Ondrej Oprala
On 10.08.2015 22:19, Chet Ramey wrote: On 8/9/15 1:37 PM, aixtools wrote: Hi, Via google I came across the define named config-top.h:/* #define SYSLOG_HISTORY */ Changing it (manually) to config-top.h:#define SYSLOG_HISTORY Adds syslog statements such as: Aug 9 16:52:55 x064 user:info syslo