bug-bash
[Top][All Lists]
Advanced

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

Re: odd behavior from overloading the "source" builtin


From: Chris F.A. Johnson
Subject: Re: odd behavior from overloading the "source" builtin
Date: Sun, 16 Mar 2014 18:02:08 -0400 (EDT)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)

On Sun, 16 Mar 2014, Doug McIlroy wrote:

GNU bash, version 4.2.39(1)-release (x86_64-redhat-linux-gnu)
interprets this shell script differently when bash input comes from a terminal or when it conmes from a file:
        source(){
        echo x
        }
        source
In the former case it prints x; in the latter it gives a
missing-filename diagnostic, presumably from the builtin "source".
The behavior is independent of whether the environment
contains "source()".

The bash man page leads me to expect the former behavior
because commands are said to be looked up first among
shell functions, then among builtins.

The behavior seems to be peculiar to "source". If "source"
is replaced by "wait, the difference vanishes.

   I get the same behaviour whether entered in a terminal or executed
   in a script (bash 4.2 and 4.3).

$ source(){
  echo x
}
$ source
x
$ xx.sh
x



reply via email to

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