On Mon, 2010-05-31 17:55:26 +0100, A. Dreyer (LUG-OWL) <[email protected]> 
wrote:
> On 31/05/10 16:34, Jan-Benedict Glaw wrote:
> > Input:
> >     asdf, "Foo this is", NULL, 17.3
> > 
> > Output soll sein, daß
> > 
> >     $1 = adsf,
> >     $2 = Foo this is,
> >     $3 = NULL,
> >     $4 = 17.3
> > 
> > ist. Klappt auch, solange man
> > 
> >     set asdf, "Foo this is", NULL, 17.3
> > 
> > macht, scheint aber fehlzuschlagen, wenn der Text aus einer Variablen
> > kommt:
> > 
> > #!/usr/bin/env sh
> > echo ${BASH_VERSION}
> > set foo "bar baz" stuff
> > echo "1: $1    2: $2   3: $3"
> > X='foo "bar baz" stuff'
> > set $X
> > echo "1: $1    2: $2   3: $3"
> > set `echo $X`
> > echo "1: $1    2: $2   3: $3"
> > 
> > 
> > Das ergibt dann:
> > 
> > 3.1.17(1)-release
> > 1: foo    2: bar baz   3: stuff
> > 1: foo    2: "bar   3: baz"
> > 1: foo    2: "bar   3: baz"
> > 
> > 
> > Erwartet hätte ich in allen drei Fällen das Ergebnis der ersten Zeile.
> > Die Ergebnisse der zweiten und dritten Zeile halte ich für falsch.
> 
> Ich denke die Ausgaben sind korrekt..
> 
> > Comments?  Workarounds?
> 
> Spiel mal mit dem IFS (Input Field Separator) rum.. aber vergiss nicht
> den urspruenglichen wert zu sichern.
> 
> --snip--
> OLDIFS="$IFS"
> X='asdf, "Foo this is", NULL, 17.3'
> IFS="
> ,"
> set $X
> echo "1: $1    2: $2   3: $3"
> IFS="$OLDIFS"
> --snip--
> 
> .. da bleiben dann noch leading whitespaces aber ansonsten sollte es ok
> sein.

Mit dem IFS hatte ich schon gespielt; das machts aber nicht unbedingt
einfacher, weil dann z.B. kein Komma mehr in einem der C-Strings
auftauchen darf. Ebenso würden Geschichten wie

        foo ("This is a text with a real (\") quotation mark", 5.3);

nicht mehr ordentlich geparst werden.

Ich hab' gerade nochmal in der man page der bash gelesen, was `set'
tun sollte. Die Definition da ist etwas schwammig, würde aber IMHO
meine Erwartungshaltung abdecken.  Vielleicht mal 'nen Bug aufmachen
und schaun, was dabei herumkommt.

MfG; JBG

-- 
      Jan-Benedict Glaw      [email protected]              +49-172-7608481
Signature of:               Träume nicht von Dein Leben: Lebe Deinen Traum!
the second  :

Attachment: signature.asc
Description: Digital signature

--
Linux mailing list [email protected]
subscribe/unsubscribe: http://lug-owl.de/mailman/listinfo/linux
Hinweise zur Nutzung: http://www.lug-owl.de/Mailingliste/hints.epo

Antwort per Email an