Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Problem mit Argumenten und Schleife
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Gunnar Ritter  
View profile   Translate to Translated (View Original)
 More options Nov 2 2001, 12:09 pm
Newsgroups: de.comp.os.unix.shell
From: Gunnar Ritter <g...@bigfoot.de>
Date: Fri, 02 Nov 2001 18:07:31 +0100
Local: Fri, Nov 2 2001 12:07 pm
Subject: Re: Problem mit Argumenten und Schleife

Helmut Schellong <schell...@t-online.de> wrote:
> ---------------------------------------------
>  for vname [ in word ... ] ;do list ;done
>           Each time a for command is executed, vname is set to the next
>           word taken from the in word list. If in word ... is omitted,
>           then the for command executes the do list once for each

                                                           ^^^^^^^^
>           positional parameter that is set starting from 1 (see

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>           ``Parameter Expansion''). [Kammzitat gesnippt]
> Welcher der vier Fälle hier gilt, wird nicht beschrieben.

Doch.

Die Beschreibung in der v7-Manpage (»if in word ... is omitted then
in "$@" is assumed«) stimmte damals nämlich nicht -

$ cat t
for i in "$@"
do
        echo "$i"
done
echo -----
for i
do
        echo "$i"
done
$ sh t

-----
$

- denn ohne positionale Parameter wurde "$@" bis SVr3 (?) zu ''
expandiert und nicht zu nichts wie heute. Wohl deshalb steht schon
in der System III-Manpage genau die Formulierung, die Du oben ohne
Quellenangabe wiedergegeben hast. Man muß sie eben nur verstehen.

Somit ist »for i« stets portabler als »for i in "$@"«, zumal die
ältere Expansionsweise von »"$@"« immer noch anzutreffen ist (vgl.
<3b978...@news.uni-ulm.de>).

Grüße,
        Gunnar


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.