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

Re: eagle-lin64-7.5.0.run, won't



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Jan 16, 2016 at 09:45:58AM -0700, Brandon Vincent wrote:
> On Sat, Jan 16, 2016 at 9:42 AM, Curt <curty@free.fr> wrote:
> > Thank you for your time. Just another misapprehension I've been laboring
> > under these many years.
> 
> I actually linked to the wrong article. I've never been able to find
> actual Bash documentation that states this.
> 
> It just has always worked.

It's just there in the manual (referring to info bash):

  3.7.2 Command Search and Execution
  ----------------------------------
  
  After a command has been split into words, if it results in a simple
  command and an optional list of arguments, the following actions are
  taken.
  
    1. If the command name contains no slashes, the shell attempts to
       locate it.  If there exists a shell function by that name, that
       function is invoked as described in *note Shell Functions::.
  
    2. If the name does not match a function, the shell searches for it in
       the list of shell builtins.  If a match is found, that builtin is
       invoked.
  
    3. If the name is neither a shell function nor a builtin, and contains
       no slashes, Bash searches each element of '$PATH' for a directory
       containing an executable file by that name.  Bash uses a hash table
       to remember the full pathnames of executable files to avoid
       multiple 'PATH' searches (see the description of 'hash' in *note
       Bourne Shell Builtins::).  A full search of the directories in
       '$PATH' is performed only if the command is not found in the hash
       table.  If the search is unsuccessful, the shell searches for a
       defined shell function named 'command_not_found_handle'.  If that
       function exists, it is invoked with the original command and the
       original command's arguments as its arguments, and the function's
       exit status becomes the exit status of the shell.  If that function
       is not defined, the shell prints an error message and returns an
       exit status of 127.
       [...]

That means that all the "special handling" (i.e. looking up a shell
function, going through $PATH, etc.) only happens when the command
contains no slashes. It's only for those cases where you'd need a
"." in $PATH if you want commands in the current directory executed
right away, a custom which is discouraged, because it's too easily
a vector for exploits[1] (it used to be standard behaviour under DOS,
which was one of the surprises for DOS migrants).

If you call the "local" command ./foo, then it contains slashes, so
special behaviour doesn't apply.

- - - - - - - - - - - - - - - - -
[1] Eve puts an executable shell script under /tmp named `ls',
    containing the line "rm -Rf $HOME/". Alice does:

      cd /tmp
      ls

    and is henceforth homeless.

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlabiJgACgkQBcgs9XrR2kYe1gCdHPlM549sUht/gGW6R87YYE6S
+TMAnAshVl3y6mGei4RHesn1UrQeX1e5
=72Wo
-----END PGP SIGNATURE-----


Reply to: