Quantcast
Channel: User Edward Ned Harvey - Super User
Viewing all articles
Browse latest Browse all 17

Comment by Edward Ned Harvey on Bash scripting: test for empty directory

$
0
0
Oh no! There is a very important problem with this code. It should be if [ -n "$(ls -A /path/to/dir)" ]; then ... Please update the answer before someone pastes this code into their server somewhere and a hacker figures out how to exploit it. If /path/to/dir isn't empty, then the filenames there get passed as arguments to /bin/test which is clearly not intended. Just add the -n argument, problem solved. Thanks!

Viewing all articles
Browse latest Browse all 17

Trending Articles