Re: Trouble in the variable expansion

2013-11-20 Thread Seb
Le Sun, 17 Nov 2013 22:50:14 + (UTC)
Thorsten Glaser a écrit:

 Seb dixit:
 
 [ ${x#X} = $y ] || echo BUG the 2nd!
 
 I think this must be … = $y to be fair. But that was not the
 problem.

Actually, I should have used a constant in the second parts in all the
tests, it would have been more accurate.

 And here are the results you get running it with different shells:
 
 tg@blau:~ $ mksh debug.sh a b c
 3
 2
 1
 tg@blau:~ $ mksh -c 'print $KSH_VERSION'
 @(#)MIRBSD KSH R48 2013/11/17
 
 Fixed in CVS HEAD now.

I wanted to test, but what I fetch with cvs by following the
instructions from the mksh's web page does not compile. This is the
only thing I get:

 In file included from lalloc.c:21:0:
 sh.h:671:24: fatal error: sh_flags.gen: No such file or directory
 compilation terminated

Chair/keyboard interface problem (I'm not familiar at all with
cvs) or not? :)

Take care,
Seb.


Re: Trouble in the variable expansion

2013-11-17 Thread Thorsten Glaser
Seb dixit:

It seems there is a problem in the way the R48b deals with the
spaces in the variables. Below is a piece of code showing the strange

Thanks for bringing this to my attention. Indeed, there appears to be
field splitting not done correctly, but at least it’s not m̲y̲ fault ☺

tg@frozenfish:~ $ pdksh -c 'x=X 1; echo shift ${x#X}'
shift  1

(That on Debian etch.)


Looking further¹:

tg@blau:~ $ x=X 1; dumpargs shift ${x#X}
args(3) 0:/usr/local/bin/dumpargs 1:shift 2: 3:1
tg@blau:~ $ x=X 1 2; dumpargs shift ${x#X}
args(4) 0:/usr/local/bin/dumpargs 1:shift 2: 3:1 4:2

So, apparently, the leading space creates an empty field.

Meh. On the other hand…

tg@blau:~ $ mksh /usr/src/contrib/code/Snippets/ifs.sh
# tests 6856 passed 6856 failed 0

The script – now http://www.research.att.com/~astopen/public/ifs.sh
as everything ~gsf/ seems to have been moved – hasn’t changed either,
which means you found something not covered by any existing tests.

I’ll look at this.

bye,
//mirabilos

① https://www.mirbsd.org/cvs.cgi/contrib/hosted/tg/dumpargs?rev=HEAD
-- 
„Also irgendwie hast du IMMER recht. Hier zuckelte gerade ein Triebwagen mit
der Aufschrift Ostdeutsche Eisenbahn durch Wuppertal. Ich glaubs machmal
nicht…“ -- Natureshadow, per SMS
„Hilf mir mal grad beim Denken“ -- Natureshadow, IRL, 2x