tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

shell prefix/suffix removal with quoted word



It has been brought to my attention that quoting the "word" in sh's 
substring processing causes word to be matched literally rather than 
being treated as a pattern. I.e.,
	x="abc"
	y="?"
	echo "${x#"$y"}"
outputs "abc", while
	x="abc"
	y="?"
	echo "${x#$y}"
outputs "bc".

I can't see this behaviour specified by SUS nor mentioned in sh(1).
bash and ksh seem to behave the same.


Home | Main Index | Thread Index | Old Index