bug-bash
[Top][All Lists]
Advanced

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

Re: Incorrect manage "*" in test -z


From: Guillermo Buritica Tobon
Subject: Re: Incorrect manage "*" in test -z
Date: Fri, 17 Apr 2015 10:03:21 +1000

Sorry I forgot the main version.

I have tested in: all show the same issue.


*******************************************************
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Red Hat Enterprise Linux Server release 6.6 (Santiago)
Red Hat Enterprise Linux Server release 6.6 (Santiago)
4.1.2(1)-release
*********************************************************
*********************************************************
CentOS Linux release 7.0.1406 (Core) 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CentOS Linux release 7.0.1406 (Core) 
CentOS Linux release 7.0.1406 (Core) 

echo $BASH_VERSION
4.2.45(1)-release
***********************************************************

***********************************************************
PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=raspbian
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
echo $BASH_VERSION
4.2.37(1)-release
***********************************************************

***********************************************************
FreeBSD  10.1-STABLE FreeBSD 10.1-STABLE #0 r280048: Mon Mar 16 10:26:18 UTC 2015     address@hidden:/usr/obj/arm.armv6/usr/src/sys/RPI-B  arm
echo $BASH_VERSION
4.3.33(0)-release
***********************************************************


Kind Regards

Guillermo B


On Fri, Apr 17, 2015 at 9:51 AM, Guillermo Buritica Tobon <address@hidden> wrote:
Hi All.

H have the next bash script code.: 

#!/bin/sh
# Pring OK on empty input, 
# Print input on non-empty input

read INPUT
if [ -z "$INPUT" ]; then
        echo OK
else
        echo $INPUT
        while read INPUT; do
                echo $INPUT
        done
fi


The function read one input and print the input or print "OK" if the input is enpty

Example correct use:

echo "Hello World" | ~/OkIfNoInput.sh
Hello World

echo "" | ~/OkIfNoInput.sh
OK

The ISSUE is when the string Contain "*" the results are very estrange. or "*[space]" 

echo "* Hello World *" |  ~/OkIfNoInput.sh
forensic orbit-gtobon postgresql-2015-04-13_000000.log qt_temp.kn3231 qt_temp.Lh3231 qt_temp.nS3231 qt_temp.T28137 query.html server.log smartgrep_60863524962e4077d558766bf2f79235a373cae448da3e11b384b37e7d2f1ea8 ssh-Mxs2Qb6AhJxc systemd-private-1AfwYz systemd-private-2stQfP systemd-private-2ytw5H systemd-private-3xYsUI systemd-private-44tvlt systemd-private-4FOgxG systemd-private-cfGpBQ systemd-private-d6PHV1 systemd-private-EQaIzh systemd-private-FZx2ad systemd-private-GJzO5O systemd-private-GTYlPD systemd-private-H72F9i systemd-private-I6N6mv systemd-private-isBta7 systemd-private-m70a9b systemd-private-missS7 systemd-private-mPbVbC systemd-private-noY0rf systemd-private-nZbmwS systemd-private-obDFE9 systemd-private-OfXH6S systemd-private-P6I7QK systemd-private-PI2Kf0 systemd-private-Q8dNwo systemd-private-qiMHMr systemd-private-QiOvUZ systemd-private-RO0WgV systemd-private-t2Slaz systemd-private-UH50C8 systemd-private-yJIqqS tt.txt zabbix_server_5662.pinger zabbix_server_5680.pinger Hello World forensic orbit-gtobon postgresql-2015-04-13_000000.log qt_temp.kn3231 qt_temp.Lh3231 qt_temp.nS3231 qt_temp.T28137 query.html server.log smartgrep_60863524962e4077d558766bf2f79235a373cae448da3e11b384b37e7d2f1ea8 ssh-Mxs2Qb6AhJxc systemd-private-1AfwYz systemd-private-2stQfP systemd-private-2ytw5H systemd-private-3xYsUI systemd-private-44tvlt systemd-private-4FOgxG systemd-private-cfGpBQ systemd-private-d6PHV1 systemd-private-EQaIzh systemd-private-FZx2ad systemd-private-GJzO5O systemd-private-GTYlPD systemd-private-H72F9i systemd-private-I6N6mv systemd-private-isBta7 systemd-private-m70a9b systemd-private-missS7 systemd-private-mPbVbC systemd-private-noY0rf systemd-private-nZbmwS systemd-private-obDFE9 systemd-private-OfXH6S systemd-private-P6I7QK systemd-private-PI2Kf0 systemd-private-Q8dNwo systemd-private-qiMHMr systemd-private-QiOvUZ systemd-private-RO0WgV systemd-private-t2Slaz systemd-private-UH50C8 systemd-private-yJIqqS tt.txt zabbix_server_5662.pinger zabbix_server_5680.pinger


echo "*" |  ~/OkIfNoInput.sh
forensic orbit-gtobon postgresql-2015-04-13_000000.log qt_temp.kn3231 qt_temp.Lh3231 qt_temp.nS3231 qt_temp.T28137 query.html server.log smartgrep_60863524962e4077d558766bf2f79235a373cae448da3e11b384b37e7d2f1ea8 ssh-Mxs2Qb6AhJxc systemd-private-1AfwYz systemd-private-2stQfP systemd-private-2ytw5H systemd-private-3xYsUI systemd-private-44tvlt systemd-private-4FOgxG systemd-private-cfGpBQ systemd-private-d6PHV1 systemd-private-EQaIzh systemd-private-FZx2ad systemd-private-GJzO5O systemd-private-GTYlPD systemd-private-H72F9i systemd-private-I6N6mv systemd-private-isBta7 systemd-private-m70a9b systemd-private-missS7 systemd-private-mPbVbC systemd-private-noY0rf systemd-private-nZbmwS systemd-private-obDFE9 systemd-private-OfXH6S systemd-private-P6I7QK systemd-private-PI2Kf0 systemd-private-Q8dNwo systemd-private-qiMHMr systemd-private-QiOvUZ systemd-private-RO0WgV systemd-private-t2Slaz systemd-private-UH50C8 systemd-private-yJIqqS tt.txt zabbix_server_5662.pinger zabbix_server_5679.pinger



This is an expected result?
I'm doing something wrong?
Or is this a bug in bash?



Kind Regards


Guillermo Buritica T.


reply via email to

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