bug-bash
[Top][All Lists]
Advanced

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

bash 4.4 changed behavior wrt to builtin 'command'


From: Reto
Subject: bash 4.4 changed behavior wrt to builtin 'command'
Date: Mon, 7 Aug 2017 17:32:21 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hi,

Not sure if it's a bug or intended behavior, but in bash 4.4 the behavior changed with respect to builtin command 'command', called with /bin/sh.

While in bash 4.3 the following works:

    # /bin/sh --version
    GNU bash, version 4.3.43(1)-release (x86_64-redhat-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    # /bin/sh -c 'command(){ echo FOO;}; command'
    FOO
    #


It does not work anymore in bash 4.4:

    # /bin/sh --version
    GNU bash, version 4.4.12(1)-release (x86_64-redhat-linux-gnu)
    Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    # /bin/sh -c 'command(){ echo FOO;}; command'
    /bin/sh: `command': is a special builtin
    #

AFIK 'command' is no built in command in bourne shell,
so I think it could be expected that if bash is called with /bin/sh 'command' can be used as function name?

trying with other builtin commands in 4.3 and 4.4:

- 'shift' and 'exec' are bourne shell builtins (so it's expected they fail in /bin/sh case, not sure why it works in bash case?)

- 'bg' and 'command' are just bash builtins (so expected it works in /bin/sh case (it does for 'bg' but not for 'command'?), not sure why it works in bash case?)

    bash4.3.43# /bin/sh -c 'shift(){ echo FOO;}; shift'
    /bin/sh: `shift': is a special builtin
    bash4.3.43# /bin/bash -c 'shift(){ echo FOO;}; shift'
    FOO
    bash4.3.43# /bin/sh -c 'bg(){ echo FOO;}; bg'
    FOO
    bash4.3.43# /bin/bash -c 'bg(){ echo FOO;}; bg'
    FOO
    bash4.3.43# /bin/sh -c 'exec(){ echo FOO;}; exec'
    /bin/sh: `exec': is a special builtin
    bash4.3.43# /bin/bash -c 'exec(){ echo FOO;}; exec'
    FOO
    bash4.3.43#  /bin/sh -c 'command(){ echo FOO;}; command'
    FOO
    bash4.3.43#  /bin/bash -c 'command(){ echo FOO;}; command'
    FOO
    bash4.3.43#


    bash4.4.12# /bin/sh -c 'shift(){ echo FOO;}; shift'
    /bin/sh: `shift': is a special builtin
    bash4.4.12# /bin/bash -c 'shift(){ echo FOO;}; shift'
    FOO
    bash4.4.12# /bin/sh -c 'bg(){ echo FOO;}; bg'
    FOO
    bash4.4.12# /bin/bash -c 'bg(){ echo FOO;}; bg'
    FOO
    bash4.4.12# /bin/sh -c 'exec(){ echo FOO;}; exec'
    /bin/sh: `exec': is a special builtin
    bash4.4.12# /bin/bash -c 'exec(){ echo FOO;}; exec'
    FOO
    bash4.4.12# /bin/sh -c 'command(){ echo FOO;}; command'
    /bin/sh: `command': is a special builtin
    bash4.4.12# /bin/bash -c 'command(){ echo FOO;}; command'
    FOO
    bash4.4.12#


regards
Reto



reply via email to

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