[Top][All Lists]

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

Why does this work

From: Stephan Austermühle
Subject: Why does this work
Date: Wed, 30 Jan 2002 11:57:51 +0100
User-agent: Mutt/1.2.5i


I'd like to access the script name ($0) in a shell function. I can do
this with


        function myfunction {
                set -- $0

                echo "Parameters: $*"
                echo "Count: $#"
                return 0

        myfunction test bla blub

Invoking the script returns

        $ ./fct.sh a b c
        Parameters: ./fct.sh
        Count: 1

Removing the "set..." line returns

        $ ./fct.sh a b c
        Parameters: test bla blub
        Count: 3

My questions are:

- Why gives the "set" statement as listed above access to the script
- Why does this work with bash but not with ksh?

Thanks very much for your answer and please excuse the posting if this
isn't the right list.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]