David Haller wrote:
On Thu, 20 Jan 2011, David C. Rankin wrote:
I stumbled across a neat use of ls -A for testing for an empty dir that I thought I would pass on:
#!/bin/bash
if [[ $(ls -A ${1}) ]]; then ^^^^ *BLAM* _ALWAYS_ QUOTE ARGUMENTS
And I'd prefer the more readable and portable
if test -n "$(ls -A "$1")"; then
David, I know that you know it; but for the sake of the archives: Quotes are wrong, that should be "$(ls -A \"$1\")". If the directory name starts with an hyphen, it'll get an error, too. So better make it "$(ls -A -- \"$1\")". Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod Email: jschrod@acm.org Roedermark, Germany -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org