[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
`$x` adds single quotes during interpolation under Wrong Circumstances
From: |
philo vivero |
Subject: |
`$x` adds single quotes during interpolation under Wrong Circumstances |
Date: |
Mon, 29 Mar 2004 12:33:06 -0800 |
Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: i586-mandrake-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i586'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-mandrake-linux-gnu'
-DCONF_VENDOR='m
uname output: Linux tworktop 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST
2003 i686 unknown unknown GNU/Linux
Machine Type: i586-mandrake-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
Doing `$x` will add single-quotes sometimes -- but not always.
It won't add single-quotes if $x doesn't contain escaped
characters. This makes it impossible in some shell scripts to
get desired/intended behaviour and in any case seems backwards.
If the author has bothered to escape things, he should be able
to undestand how to do multiple escapes for multiple
interpolations.
Just to clarify, if you don't understand why this is important,
the bug was discovered when calling a function, say
"cleanlogs()" with the arguments "/var/log \*log.\*" and then
there being a file in the home directory called
install.log.syslog (which matches) and thus a subsequent find
becoming "find /var/log -name 'install.log.syslog'" which
clearly wasn't what was intended.
Repeat-By:
# touch install.log.syslog
# set -x
# a=\*log.\*
+ a=*log.*
# FILE=`echo $a`
++ echo install.log.syslog # it gets wildcard-interpolated
+ FILE=install.log.syslog
# a=\\\*log.\\\*
+ a=\*log.\*
# FILE=`echo $a`
++ echo '\*log.\*' # !!!!!!!!!!!!!!!!
+ FILE=\*log.\*
# set +x
# bash --version
GNU bash, version 2.05b.0(1)-release (i586-mandrake-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
Fix:
Either always or never add single quotes when doing backtick
interpolation on a variable.
--
pv
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- `$x` adds single quotes during interpolation under Wrong Circumstances,
philo vivero <=