Shellowa zagadka

Przemyslaw Iskra sparky at pld-linux.org
Thu May 5 20:48:50 CEST 2011


On Thu, May 05, 2011 at 08:29:11PM +0200, Kacper Kornet wrote:
> Przy okazji wyjścia nowej wersji git'a trafiłem na następującą zagwozdkę
> na naszym /bin/sh. Otóż skrypt:
> 
> x=2; unset a; echo "${a:-'$x'}"
> 
> zwraca:
> 
> $x
> 
> Natomiast bash, zsh, dash i ash zwracają '2' w tym wypadku. Pytanie do
> znawców: co jest poprawne z punktu widzenia POSIX.

Nie opisane.

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02


If a parameter expansion occurs inside double-quotes:

* Pathname expansion shall not be performed on the results of the expansion.
* Field splitting shall not be performed on the results of the
  expansion, with the exception of '@'


Lepiej unikać ${nazwa:COŚTAM} wewnątrz "" i tyle.


Best regards,
	Przemysław Iskra.

-- 
 ____    sparky  --  Przemyslaw  ................ LANG...Pl,Ca,Es,En
/____) ___  ___  _ _ || Iskra   : WWW . http://ppcrcd.pld-linux.org/
\____\| -_)'___| ||^'||//\\//   : WWW2 ............ http://rsget.pl/
(____/||   (_-_|_||  ||\\ ||    : eMail ..... <sparky w pld-linux.org>


More information about the pld-devel-pl mailing list