\W and \w doesn't substitute $HOME for ~ properly

2006-09-30 Thread carl
Configuration Information [Automatically generated, do not change]:
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-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -march=k8 -O2 -pipe
uname output: Linux chicago 2.6.17-gentoo-r8 #1 PREEMPT Fri Sep 15 12:15:25 
CEST 2006 x86_64 AMD Turion(tm) 64 Mobile Technology ML-30 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

Description:
If a user has it's home directory specified with a trailing
slash, such as /home/johndoe/, instead of /home/johndoe, in
/etc/passwd, prompting doesn't work properly.

If PS1, and perhaps other prompts, has the \w or the \W
which should be substituted with a tilde while the user is
in his/her home directory, it isn't. Instead it shows
"johndoe" or equivalent.

Repeat-By:
export PS1='\[\033[01;35m\] \W \[\033[0;35m\]\$ \[\033[00m\]'
and set your home directory to whatever it already is, but
with a trailing slash.

Fix:
Since there is no definite practice to wether a directory
should be specified with or without trailing slash when
the directory itself is to be specified, best practice should
be to interpret both as the directory.


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


"." (aka source) works only with regular files

2006-09-30 Thread stephane_chazelas
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
uname output: Linux sc 2.6.17.11 #1 PREEMPT Sun Sep 24 13:29:05 BST 2006 i686 
GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

Description:
$ echo echo echo | bash -c '. /dev/fd/0'
$ echo echo echo | zsh -c '. /dev/fd/0'
echo
$ echo echo echo | ksh -c '. /dev/fd/0'
echo
$ echo echo echo | ash -c '. /dev/fd/0'
echo
$ echo echo echo | posh -c '. /dev/fd/0'
echo

Same problem if you do a ". fifo".


$ echo echo echo | strace bash -c '. /dev/fd/0'
[...]
stat64("/dev/fd/0", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
open("/dev/fd/0", O_RDONLY|O_LARGEFILE) = 5
fstat64(5, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
read(5, "", 0)  = 0
[...]

The problem being that bash does a stat on the file, and reads
st_size bytes from the file only, instead of reading til eof.


Repeat-By:
echo echo echo | bash -c '. /dev/fd/0'

Fix:
Not use stat(2).

I think the file should be read the same way as standard input
is read.

Like

echo 'echo echo echo >> a' > a
. ./a

should output "echo". (It does with ash, pdksh and zsh, not with
AT&T ksh). SUSv3 is not specific on that case.

-- 
Stephane


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash