bug-bash
[Top][All Lists]
Advanced

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

Re: BASH_ARGV -- arguments are reversed


From: Clark Wang
Subject: Re: BASH_ARGV -- arguments are reversed
Date: Fri, 28 Nov 2014 13:38:34 +0800

On Fri, Nov 28, 2014 at 1:07 PM, William Park <opengeometry@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

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