[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Empty sub-string expansion bug
From: |
David Purdy |
Subject: |
Empty sub-string expansion bug |
Date: |
Tue, 24 Oct 2006 15:50:12 +0200 |
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 lnxdavid 2.6.17-2-686 #1 SMP Wed Sep 13 16:34:10 UTC 2006
i686 GNU/Linux
Machine Type: i486-pc-linux-gnu
Bash Version: 3.1
Patch Level: 17
Release Status: release
Description:
Substring operations that are meant to return an empty string ""
sometimes return character "\177" instead.
Repeat-By:
A=""
B="${A:0}"
touch "/tmp/test/TEST${A:0}"
-> touch: cannot touch `/tmp/test/TEST\177': No such file or directory
touch "/tmp/test/TEST$B"
-> touch: cannot touch `/tmp/test/TEST': No such file or directory
The example above is contrived, here is another (more realistic)
example:
A="abc"
touch "/tmp/test/TEST${A:3}"
-> touch: cannot touch `/tmp/test/TEST\177': No such file or directory
Fix:
Bash script work-around: Use an intermediate variable until the bug is
fixed.
- Empty sub-string expansion bug,
David Purdy <=