Skip to main content
1 of 3

This is a safe design.

nullglob would be the safe default for commands that are void when argument is void. This is not the case whith ls. nullglob is useful in scripts, but is not safe unless you replace ls by a function like this :

myls() { (($#)) && ls "$@" ; }

So you have the expected result when you do this :

shopt -s nullglob
myls empty_directory/*

Designers have taken the safe option, because many commands take implicit value when no argument is given, often giving a behavior that is not consistent with the semantic of nothing.