Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Enable nullglobs to prevent string literal bug in various for loops #11

Merged
merged 1 commit into from Sep 21, 2016
Merged

Enable nullglobs to prevent string literal bug in various for loops #11

merged 1 commit into from Sep 21, 2016

Conversation

zestysoft
Copy link
Contributor

Take this code as an example:

for i in /nsm/sensor_data/*/stats.log; do
echo "$i"
if [ $( tail -n 50 $i | grep -c drop ) -ne 0 ]; then

If there are no files that match '/nsm/sensor_data//status.log', the
non-intuitive default setting in shell scripts is to assign the literal
'/nsm/sensor_data/
/status.log' to $i. This then breaks the following if
statement because tail is being passed a filename with a wildcard in it.

Take this code as an example:

for i in /nsm/sensor_data/*/stats.log; do
        echo "$i"
        if [ $( tail -n 50 $i | grep -c drop ) -ne 0 ]; then

If there are no files that match '/nsm/sensor_data/*/status.log', the
non-intuitive default setting in shell scripts is to assign the literal
'/nsm/sensor_data/*/status.log' to $i.  This then breaks the following if
statement because tail is being passed a filename with a wildcard in it.
@dougburks
Copy link
Contributor

Thanks @zestysoft !

@dougburks dougburks merged commit 25babab into Security-Onion-Solutions:master Sep 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants