The result of bash's indirect expansion differs between RHEL6 and RHEL7.

Solution Verified - Updated -

Issue

  • The result of bash's indirect expansion differs between RHEL6 and RHEL7.
  • Bash in RHEL7 cannot get the last argment value using ${!#}.

    For example:

    $ cat test.sh
    !#/bin/sh
    echo ${!#}
    
    (In the case of RHEL6)
    $ test.sh a b c
    c
    $
    
    (In the case of RHEL7)
    $ test.sh a b c
    $
    
  • When did it change?

Environment

  • Red Hat Enteprise Linux 7
    • bash-4.2
  • Red Hat Enteprise Linux 6
    • bash-4.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In