help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Inconsistency of the behavior of `source` with and without a


From: Peng Yu
Subject: [Help-bash] Inconsistency of the behavior of `source` with and without arguments in function
Date: Fri, 17 Jul 2015 19:51:39 -0500

Hi, The following code shows that $@ is treated differently when
`source` is used with and without arguments in `function`. Isn't it
better to make `source` always pass "$@" from the source script back
to the external script whether arguments are used with `source` or
not?

~$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

function f {
echo aaa "$@"
source source.sh "$@"
echo bbb "$@"
}

f 1 2 3

function g {
echo aaa "$@"
source source.sh
echo bbb "$@"
}

g 1 2 3
~$ cat source.sh
set -- a b c --
~$ ./main.sh
aaa 1 2 3
bbb 1 2 3
aaa 1 2 3
bbb a b c --


-- 
Regards,
Peng



reply via email to

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