Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11855 > unrolled thread
| Started by | Grisha Levit <grishalevit@gmail.com> |
|---|---|
| First post | 2015-11-09 22:59 -0800 |
| Last post | 2015-11-10 09:31 -0500 |
| Articles | 2 — 2 participants |
Back to article view | Back to gnu.bash.bug
BASH_ARG{C,V} set when sourcing, even without extdebug Grisha Levit <grishalevit@gmail.com> - 2015-11-09 22:59 -0800
Re: BASH_ARG{C,V} set when sourcing, even without extdebug Chet Ramey <chet.ramey@case.edu> - 2015-11-10 09:31 -0500
| From | Grisha Levit <grishalevit@gmail.com> |
|---|---|
| Date | 2015-11-09 22:59 -0800 |
| Subject | BASH_ARG{C,V} set when sourcing, even without extdebug |
| Message-ID | <8daf3fe2-18e2-48d5-9c1f-fb9ee5c1b4c6@googlegroups.com> |
It looks like the source builtin pushes its own argc and argv onto the arrays but only if it is called with no other arguments.
$ cat /tmp/s
fun() { declare -p BASH_ARGC BASH_ARGV; }
fun arg
$ shopt -u extdebug; source /tmp/s
declare -a BASH_ARGC=([0]="1")
declare -a BASH_ARGV=([0]="/tmp/s")
$ shopt- u extdebug; source /tmp/s foo
declare -a BASH_ARGC=()
declare -a BASH_ARGV=()
[toc] | [next] | [standalone]
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Date | 2015-11-10 09:31 -0500 |
| Message-ID | <mailman.2062.1447165897.7904.bug-bash@gnu.org> |
| In reply to | #11855 |
On 11/10/15 1:59 AM, Grisha Levit wrote: > It looks like the source builtin pushes its own argc and argv onto the arrays but only if it is called with no other arguments. Yes, bash has always done this as a convenience. This is a way to get the name of the sourced file in the common case. When given additional arguments, bash sets BASH_ARGC and BASH_ARGV only when debugging mode is in effect. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
[toc] | [prev] | [standalone]
Back to top | Article view | gnu.bash.bug
csiph-web