On Thu, 23 Jul 2009 03:25:56 +0200 Christoph Anton Mitterer <christoph.anton.mitte...@physik.uni-muenchen.de> wrote: > Package: dash > Version: 0.5.5.1-2 > Severity: normal > > Hi. > > I've made some scripts where I pre-process an arbitrary file name for > some sed- and grep expressions. > As e.g. . and / (which can occur in filenames) may have special > meaning to sed and grep, I quote the each character of the filename > with \ before using it further. > > I do about this: > file='./data/image.oga' > echo $file > echo "$file" > > file_entry_quoted="$( printf "${file}" | sed --regexp-extended > 's/(.)/\\\1/g' )" > echo $file_entry_quoted > echo "$file_entry_quoted" > > under bash this gives me: > ./data/image.oga > ./data/image.oga > \.\/\d\a\t\a\/\i\m\a\g\e\.\o\g\a > \.\/\d\a\t\a\/\i\m\a\g\e\.\o\g\a > > under dash I get: > ./data/image.oga > ./data/image.oga > \.\/\d \/\i\m\g\e\.\o\g > \.\/\d \/\i\m\g\e\.\o\g > (that's a tab after the d, the \a seem to be replaced by 0x7) > > > With the `` style of command substitution it's even "worse" in dash,... > file_entry_quoted="` printf "${file}" | sed --regexp-extended > 's/(.)/\\\1/g' `" > In that case,.. each character is replaced by 0x1. > > The \a and 0x1 thingy is strange anyway, isn't it? > But I'd even haven't expected that \t would be replaced as POSIX says > ( http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03 ): > "The results of command substitution shall not be processed for > further tilde expansion, parameter expansion, command substitution, or > arithmetic expansion. If a command substitution occurs inside > double-quotes, field splitting and pathname expansion shall not be > performed on the results of the substitution." > > Or do I misunderstand something? > > > Another thing where bash and dash behave differently is: > fo='\\' > echo $fo > echo "$fo" > > gives in bash: > \\