Why $0 shows as "-bash", not the script name?
test(){
echo $0 echo $1 echo $2 } run "test 1 2", and it gives -bash 1 2 I expect test 1 2 |
Quote:
Here is the output when i run it. Code:
test Code:
test() |
How are you calling it
Code:
bash yourscript |
Actually the op is saying run "test 1 2".
Your $0 is run (under bash) and "test" is "shift"ed out. OK |
Quote:
Code:
c@CW8:~$ type run |
I think the most robust method is by using the appropriate bash variables. This avoid confusion between executed and sourced scripts. There is also a specific variable to retrieve function names:
Code:
#!/bin/bash Code:
$ ./test.sh |
Quote:
|
All times are GMT -5. The time now is 10:56 PM. |