|
From: | Dennis Williamson |
Subject: | Re: Incorrect manage "*" in test -z |
Date: | Fri, 17 Apr 2015 05:54:18 -0500 |
Hi All.H have the next bash script code.:#!/bin/sh# Pring OK on empty input,# Print input on non-empty inputread INPUTif [ -z "$INPUT" ]; thenecho OKelseecho $INPUTwhile read INPUT; doecho $INPUTdonefiThe function read one input and print the input or print "OK" if the input is enptyExample correct use:echo "Hello World" | ~/OkIfNoInput.shHello Worldecho "" | ~/OkIfNoInput.shOKThe ISSUE is when the string Contain "*" the results are very estrange. or "*[space]"echo "* Hello World *" | ~/OkIfNoInput.shforensic 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.pingerecho "*" | ~/OkIfNoInput.shforensic 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.pingerThis is an expected result?I'm doing something wrong?Or is this a bug in bash?Kind RegardsGuillermo Buritica T.
[Prev in Thread] | Current Thread | [Next in Thread] |