Philip Guenther <[email protected]> wrote: > On Fri, Dec 25, 2015 at 12:16 PM, Thorsten Glaser <[email protected]> wrote: > > Hello J?rg, > > > >>> * of command substitution, <backslash> shall > >>> * retain its literal meaning, except when > >>> * followed by: '$', '`', or <backslash>. The > > > >>Am I missing someting? I cannot see a \ before $ ` or \ > >>in the example code. > > > > I read ?shall retain its literal meaning? as ?the > > backslash should stay a backslash and not be an > > escape character?. That means? > > directory="`basename \"$ACRO_INSTALL_DIR\"`" > > becomes > > directory="$(basename \"$ACRO_INSTALL_DIR\")" > > and not > > directory="$(basename "$ACRO_INSTALL_DIR")" > > as in ?common/non-POSIX? mode. (The outer quotes are, > > of course, redundant for the $(?) comsub style.) > > Hmm, aren't the outer quotes redundant (modulo the backslash effect) > for *both* comsub styles? In the value of an assignment, the only > thing the double-quotes would suppress is tilde expansion. If you put > them directly around a command expansion then they don't contain a > literal tilde, so they have no effect except to make it more > complicated to type and read (and parse for the shell).
They are redundant. The inner quotes are handled according to the rules. For a verification I would say that in case that Bourne Shell, ksh88 and ksh93 agree, there is nothing wrong. The problem with the POSIX text is that it does not describe what happens in the Bourne Shell but is written in an abstract way and may not be 100% correct as nobody yet tried to code a shell from scratch looking only at the current definition text. What happens in the Bourne Shell and it's derivatives ksh88 and ksh93 is the following at parser output level: ACRO_INSTALL_DIR=/usr/Acroread/Reader directory="`basename \"$ACRO_INSTALL_DIR\"`" When this fed into the interpreter, file name expansion, macro expansion and command substitution takes place and after parsing the backquote part, the following is fed into the interpreter while doing comand substitution: basename "$ACRO_INSTALL_DIR" The interpreter then applies file name expansion, macro expansion and command substitution on this and while doing this, the double quotes are removed. This results in: basename /usr/Acroread/Reader In other words, a shell implementation where the file name expansion, macro expansion and command substitution part does not remove the double quotes does not look correct. Jvrg -- EMail:[email protected] (home) Jvrg Schilling D-13353 Berlin [email protected] (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/'
