[Toybox] Shell corner cases.

Chet Ramey chet.ramey at case.edu
Tue Apr 29 06:53:56 PDT 2025


On 4/28/25 6:03 PM, Rob Landley wrote:
> FYI, I'd prefer not to implement either of these in toybox:
> 
> 1) function names with / in them
> 
>    $ which sudo
>    /usr/bin/sudo
>    $ /usr/bin/sudo() { echo owned; }
>    $ /usr/bin/sudo
>    owned
>    $ ./sudo() { echo still owned; }
>    $ ./sudo
>    still owned

Sure, probably a good idea. POSIX execution rules say they'd never be
called anyway.

> 
> 2) deferred alias definitions
> 
>    $ alias potato='echo hello'; potato
>    bash: potato: command not found
>    $ potato
>    hello

I'm not sure what `deferred' means here. The shell reads a line of input,
parses it into a command (a list with two elements in this case), then
executes the command. Since alias expansion happens when the command is
read and tokenized, the list will be parsed before any of the commands
are executed. This is how Bourne-style shells work.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet at case.edu    http://tiswww.cwru.edu/~chet/


More information about the Toybox mailing list