On Fri, Nov 28, 2014 at 1:07 PM, William Park <opengeome...@yahoo.ca> wrote:

> Hi all,
>
> I just noticed that BASH_ARGV contains commandline arguments in reverse.
>

That's because it's a stack. According the bash manual: "The final
parameter of the last subroutine call is at the top of the stack; the first
parameter of the initial call is at the bottom."

>
>     $ cat > x.sh
>     #!/bin/sh
>     declare -p BASH_ARGV
>     ^D
>
>     $ sh x.sh 1 2 3 4 5
>     declare -a BASH_ARGV='([0]="5" [1]="4" [2]="3" [3]="2" [4]="1")'
> --
> William
>
>

Reply via email to