Declaring an empty global var as a reference in a function twice crashes bash

2015-03-22 Thread Arthur200000
Configuration Information:
Machine: x86_64
OS: darwin13.3.0
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='darwin13.3.0' -DCONF_MACHTYPE='x86_64-apple-darwin13.3.0' 
-DCONF_VENDOR='apple' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H -DMACOSX   -I.  -I. -I./include -I./lib -I./lib/int\
l -I/Users/apple/Downloads/bash-4.3/lib/intl  -arch i386 -arch x86_64 -O3 
-fomit-frame-pointer -momit-leaf-frame-pointer -ffast-math -fvisibility=hidden 
-march=core2 -mtune=corei3 -mmacosx-version-min=10.8 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platfo\
rm/Developer/SDKs/MacOSX10.8.sdk
uname output: Darwin Z 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 
19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Machine Type: x86_64-apple-darwin13.3.0

Bash Version: 4.3
Patch Level: 26
Release Status: release

Description:
When you have already set a variable to empty, running `declare -gn
varname` in a function twice crash bash with a Segment Fault.

`set -xv` told me that bash would stop right when running declare.
There is also some additional info from lldb.

I have reproduced this on my OS X and Ubuntu 14.10 LTS amd64, 
and a bash 4.3.30 on the same OS X machine, in another prefix.
The LLDB output was nearly identical.
  
Repeat-By:
Run this in bash, either as a script with she-bang or copy-paste in 
interactive shell:
```Bash
#!/bin/bash
v=''
a(){ declare -gn v; }
a; a
```

--LLDB--
* thread #1: tid = 0x922581, 0x000100074371 bash`declare_internal + 3729, 
queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x29)
frame #0: 0x000100074371 bash`declare_internal + 3729
bash`declare_internal + 3729:
-> 0x100074371:  orb$0x10, 0x29(%r14)
   0x100074376:  movq   -0x58(%rbp), %rsi
   0x10007437a:  movl   0x28(%r14), %edx
   0x10007437e:  testb  $0x2, %dl



[DOC] Documentation for `complete' compacts[] is incomplete.

2015-08-10 Thread Arthur200000
Configuration Information:
Machine: i686
OS: cygwin
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='cygwin' -DCONF_MACHTYPE='i686-pc-cygwin' -DCONF_VENDOR='pc' 
-DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H 
-DRECYCLES_PIDS   -I.  -I. -I./include -I./lib   -O1
uname output: CYGWIN_NT-10.0-WOW VAIO-lynn 2.0.4(0.287/5/3) 2015-06-09 12:20 
i686 Cygwin
Machine Type: i686-pc-cygwin

Bash Version: 4.3
Patch Level: 30
Release Status: release

Description:
Bash has incomplete documentation for builtins in `complete.def`. The 
[-abcdefgjksuv] options to specify
types to complete are not documented. This is making writing 
completions some kind of black magic.

All those correspondence can be found in complete.def. More 
specifically, compacts[].

/* By the way is anyone going to assign those '\0's so we can do even 
more things? */

Repeat-By:
help compgen, help complete, info bash, man bash.

Fix:
Write approporiate doc for this. I only need a transcription of 
compacts[] so I can look it up without Luking it.


RE: Feature Request re: syslog and bashhist

2015-08-10 Thread Arthur200000
You can add `-DSYSLOG_HISTORY` to your CFLAGS for building.

And for formatting, apply this patch:
--- bashhist.c 2015-08-11 00:09:38.449468800 +0800
+++ bashhist.c  2015-08-11 00:09:42.970623400 +0800
@@ -713,12 +713,12 @@
   char trunc[SYSLOG_MAXLEN];

   if (strlen(line) < SYSLOG_MAXLEN)
-syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", 
getpid(), current_user.uid, line);
+syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "bash[%d]: UID=%d %s", getpid(), 
current_user.uid, line);
   else
 {
   strncpy (trunc, line, SYSLOG_MAXLEN);
   trunc[SYSLOG_MAXLEN - 1] = '\0';
-  syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d 
UID=%d %s", getpid(), current_user.uid, trunc);
+  syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "bash[%d] (TRUNCATED): UID=%d %s", 
getpid(), current_user.uid, trunc);
 }
 }
 #endif

I'm not quite familiar with those configure.ac magic, and therefore I can't 
write some AC_ARG_ENABLE for you.

Re:Re: [DOC] Documentation for `complete' compacts[] is incomplete.

2015-08-10 Thread Arthur200000
At 2015-08-11 01:29:42, "Chet Ramey"  wrote:
>Have you considered reading the man page or perhaps the info doc?  That's
>where the actions are documented:
>
>  -A action
>  The  action  may  be  one of the following to generate a
>  list of possible completions:
>  alias   Alias names.  May also be specified as -a.
>  arrayvar
>  Array variable names.
>
>...and so on.

Oops, I missed it.<>

Enhancement: bash should have uniform escape syntaxes for `echo -e`, `printf` and `$'ANSI_C_style_escape'`.

2015-08-10 Thread Arthur200000
Configuration Information:
Machine Type: i686-pc-cygwin, i686-pc-msys, x86_86-linux-gnu, 
x86_64-Apple-Darwin

Bash Version: 4.3
Patch Level: 30
Release Status: release

Description:
Bash has different escape syntaxes for `echo -e`, `printf` and 
`$'ANSI_C_style_escape'`. Take a specific point, `printf` and `$'C_Style'` 
accepts octals not starting with 0, but `echo -e` doesn't. 
This is causing quite a lot of confusion.

On older versions of bash, like bash 3.2 on OS X, `echo` doesn't 
understand `\e` but `printf` and `$'C_style'` does. I believe this is quite a 
aged problem.

Repeat-By:
printf 'printf starts the bold\33[1m\n'; echo $'C escape should end 
it\33[0m'; echo -e 'echo -e does nothing but giving crap\33[1;31m'