Header Shadow Image


Why does the UNIX community continue to use deprecated bash / ksh features?

Why do all the major Linux / UNIX vendors still use the deprecated bash / ksh features?  Let's take this line as an example:

[root@mdskvm-p01 grub2]# grep platform_search_hint /boot/grub2/grub.cfg
        if [ x$feature_platform_search_hint = xy ]; then
        if [ x$feature_platform_search_hint = xy ]; then
[root@mdskvm-p01 grub2]#

This is GRUB2, the latest and greatest of the GRUB versions on RHEL 7.2.  It may not be readily apparent in the above, but the author added an x to the beginning of each side of the comparison.  This is because failing to do that will cause an error if $feature_platform_search_hint is empty.  You do NOT need to do that if the proper bash / ksh methods are practiced and double [[ ]] instead of single [ ] are used.  In the least the single backticks and the single brackets have been deprecated since 1988.  It's 2016, 28 years later.  We are doing Cloud yet we insist on using pre 1988 deprecated features.  So the following represents a list of DO's and DON'T's to follow on scripting:

Deprecated Replacement
$()
[ ] [[ ]]

Moreover, and as an example, the single bracket is a command, not a bracket:

[root@mdskvm-p01 grub2]# [
-bash: [: missing `]'
[root@mdskvm-p01 grub2]#

A good thorough overview of the non deprecated features are available at this post on Bash Hackers.

Cheers,
TK

 

 

Leave a Reply

You must be logged in to post a comment.


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License